Fix main build broken by csproj-based MSTest packaging (#9259) - #9344

Merged
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade
Jun 22, 2026
Merged

Fix main build broken by csproj-based MSTest packaging (#9259)#9344
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented Jun 22, 2026

Copy link
Copy Markdown
Member

Problem

main is broken: the latest CI builds fail in the Build/Test tasks (Windows/Linux/macOS). The failures came in layers — fixing each revealed the next. This PR fixes all of them.

#StageSymptomRoot cause
1RestoreNU1605 downgrade of Microsoft.Testing.Platform.MSBuild#9259: adapter flows the locally-built platform MSBuild transitively, conflicting with the darc-pinned PackageReference
2CompileCS0234 missing MSTestAdapter.PlatformServices types#9259: adapter sets PrivateAssets="all" on PlatformServices, hiding it from in-repo consumers
3AfterSolutionBuildverify-nupkgs.ps1 file-count mismatch for MSTest.AotReflection.SourceGeneration#9338 made the PoC packable; not added to the expected-counts table
4Test (acceptance)AnalyzersShouldBeEnabled*, MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*#9259: MSTest.TestFramework was packed with empty dependency groups — the MSTest.Analyzers dependency was dropped, so analyzers no longer ran for consumers
5RestoreNU1608 Roslyn version conflict in the source-generation unit testsfixing #4 made the analyzer projects' Microsoft.CodeAnalysis.* refs leak transitively through the framework, clashing with the pinned Roslyn 3.11.0

The xlf drift that originally broke main was already fixed by #9339.

Fixes

  • test/Directory.Build.targets — under UseMSTestFromSource, reference Microsoft.Testing.Platform.MSBuild from source so both references resolve to the same version. (NU1605)
  • MSTest.IntegrationTests / MSTestAdapter.UnitTests — add a direct ProjectReference to MSTestAdapter.PlatformServices. (CS0234)
  • eng/verify-nupkgs.ps1 — add MSTest.AotReflection.SourceGeneration = 6. (verify-nupkgs)
  • TestFramework.Extensions.csproj — remove ReferenceOutputAssembly="false" from the MSTest.Analyzers.Package reference so pack emits <dependency id="MSTest.Analyzers" include="...Analyzers,BuildTransitive" /> at the co-built version. (analyzers)
  • MSTest.Analyzers / MSTest.Analyzers.CodeFixes — mark Microsoft.CodeAnalysis.* references PrivateAssets="all" so Roslyn (a compiler-host-provided dependency) never flows to consumers. (NU1608)

The adapter's intentional PrivateAssets settings are unchanged — the produced packages keep their historical dependency graphs.

Validation

  • Reproduced each failure on clean main (/p:OfficialBuildId=20260622.12, so the build version exceeds the darc pin) and confirmed each fix resolves it.
  • Built all affected projects (integration/adapter/source-gen/analyzer unit tests) — restore + build with 0 errors; the two source-gen test projects restore without NU1608.
  • Analyzers: packed MSTest.TestFramework + MSTest.Analyzers, built a consumer referencing the package → warning MSTEST0014 fires again. The MSTest.Analyzers package still ships all analyzer assemblies with zero dependencies; the framework net462 build stays clean with analyzers active.

Refs #9259, #9338.

PR #9259 (csproj packing, removing nuspec) introduced two regressions on
MSTest.TestAdapter's project references that broke the in-repo build once the
daily build number rolled past the dogfood pin:
1. NU1605 (restore): the adapter now ProjectReferences
Microsoft.Testing.Platform.MSBuild with PrivateAssets="none", flowing the
locally built platform-MSBuild (current build version) transitively to
in-repo consumers. Test projects with UseMSTestFromSource also PackageReference
the darc-pinned version, producing a package downgrade. Reference the platform
MSBuild from source when UseMSTestFromSource is set so both paths use the same
(project) version.
2. CS0234 (compile): the adapter now suppresses MSTestAdapter.PlatformServices as
a flowed dependency (PrivateAssets="all", correct for the produced package),
so in-repo consumers no longer see its (internals-visible) types. Reference
PlatformServices directly from MSTest.IntegrationTests and MSTestAdapter.UnitTests.
Validated by building the affected projects with /p:OfficialBuildId=20260622.12
(reproducing the CI build version > pin) -- restore and compile now succeed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 14:00

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the main branch build break caused by the csproj-based MSTest.TestAdapter packaging changes (#9259) by aligning in-repo test project references with the new PrivateAssets behavior and avoiding a restore-time NU1605 downgrade scenario when UseMSTestFromSource=true.

Changes:

  • Add direct ProjectReference to MSTestAdapter.PlatformServices for test projects that compile against its types, since it no longer flows transitively from MSTest.TestAdapter due to PrivateAssets="all".
  • Replace a Microsoft.Testing.Platform.MSBuildPackageReference with a source ProjectReference when UseMSTestFromSource=true to eliminate restore downgrades against the locally-built MSBuild integration.
  • Document the rationale inline in the affected project files / targets.
Show a summary per file
FileDescription
test/UnitTests/MSTestAdapter.UnitTests/MSTestAdapter.UnitTests.csprojAdds direct reference to MSTestAdapter.PlatformServices so unit tests can compile against its APIs despite PrivateAssets="all" on the adapter’s reference.
test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csprojAdds direct reference to MSTestAdapter.PlatformServices to restore compile-time access for integration test code using those types.
test/Directory.Build.targetsSwitches Microsoft.Testing.Platform.MSBuild from PackageReference to ProjectReference under UseMSTestFromSource=true to prevent NU1605 downgrade vs the transitively-referenced source-built project.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@Evangelink

This comment has been minimized.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.

Review notes (all dimensions)

Scope: 3 MSBuild project files changed (test/Directory.Build.targets, MSTest.IntegrationTests.csproj, MSTestAdapter.UnitTests.csproj). No C# runtime code touched.

DimensionResultNotes
1. Algorithmic Correctness✅ LGTMFix correctly targets the root cause: PrivateAssets="all" on the MSTestAdapter.PlatformServicesProjectReference in MSTest.TestAdapter prevents the assembly from flowing as a compile-time reference to consumers. Adding direct ProjectReference entries in both consuming test projects restores the reference. The PackageReference→ProjectReference change in Directory.Build.targets correctly resolves the NU1605 downgrade by ensuring both the direct reference and the transitively-flowed one resolve to the same locally-built project version.
2. Threading & ConcurrencyN/ANo C# code changed.
3. Security & IPC Contract SafetyN/ABuild config changes only.
4. Public API & Binary CompatibilityN/ANo public API touched.
5. Performance & AllocationsN/ANo runtime code changed.
6. Cross-TFM Compatibility✅ LGTMMSTestAdapter.PlatformServices is built for all TFMs that MSTestAdapter.UnitTests targets (net462;net48;net8.0;net9.0;WinUiMinimum), because MSTest.TestAdapter already includes them all. The single-TFM MSTest.IntegrationTests ($(NetFrameworkMinimum)) is also covered.
7. Resource & IDisposable ManagementN/ANo code changed.
8. Defensive Coding at BoundariesN/ANo code changed.
9. Localization & ResourcesN/ANo strings changed.
10. Test IsolationN/ANo test code changed.
11. Assertion QualityN/ANo test code changed.
12. Flakiness PatternsN/ANo test code changed.
13. Test Completeness & Coverage✅ LGTMThis is a build/restore fix with no new code paths; the author validated by reproducing the failure with /p:OfficialBuildId=20260622.12 and confirming all 6 affected projects restore and build clean. No additional tests needed.
14. Data-Driven Test CoverageN/ANo test code changed.
15. Code Structure & SimplificationN/ANo C# code changed.
16. Naming & ConventionsN/ANo C# code changed.
17. Documentation Accuracy✅ LGTMAll three added XML comments accurately explain why the reference is needed (link to #9259, explain the PrivateAssets="all" mechanism). Comments describe the intent, not just what the element does.
18. Analyzer & Code Fix QualityN/ANo src/Analyzers/ files changed.
19. IPC Wire CompatibilityN/ANo serialization code changed.
20. Build Infrastructure & Dependencies✅ LGTMThe PackageReference→ProjectReference swap is gated on UseMSTestFromSource='true' (matching the old condition), sits inside the existing EnableMSTestRunner OR UseInternalTestFramework outer ItemGroup, and references a first-party in-repo project that is always resolvable. The direct ProjectReference entries in the two test projects do not duplicate the assembly in output since MSBuild deduplicates project builds. InternalsVisibleTo coverage confirmed: MSTestAdapter.PlatformServices.csproj already declares InternalsVisibleTo for both Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests and MSTest.IntegrationTests. The four other UseMSTestFromSource=true projects omitted from the fix (MSTest.VstestConsoleWrapper.IntegrationTests, MSTest.Analyzers.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests, MSTest.SelfRealExamples.UnitTests) do not consume MSTestAdapter.PlatformServices internals directly and are not listed in its InternalsVisibleTo; they build fine without an explicit reference.
21. Scope & PR Discipline✅ LGTMSingle, tightly-scoped concern. Clear description with root-cause analysis, precise reproduction steps, and explicit validation. Refs #9259 appropriately.
22. PowerShell Scripting HygieneN/ANo .ps1 files changed.
MSBuild Authoring (supplemental)✅ LGTMCondition quoting is consistent with the repo style ('$(Prop)' == 'value'). The new ProjectReference has no PrivateAssets (defaults to all-assets-flow), which is the correct behavior for a test project reference. No DependsOn append issues, no stray whitespace, no condition ordering problems.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 22, 2026
…ounts
After the build progresses past the restore/compile fixes, verify-nupkgs.ps1
fails because MSTest.AotReflection.SourceGeneration (made packable as a
non-shipping PoC in #9338) is a 4.3.0 package not present in the expected
file-count table, so it is validated with an empty expected value. Add it with
its actual content count (6: [Content_Types].xml, Icon.png, .nuspec, the
analyzer dll, .psmdcp, .rels).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ency (#9259)
After the move to csproj-based packing (#9259), MSTest.TestFramework no longer
flowed the MSTest analyzers to consumers: the package was produced with empty
dependency groups, so projects referencing MSTest.TestFramework built with the
analyzers silently disabled (acceptance tests AnalyzersShouldBeEnabled*,
MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*
all failed).
Root cause: the ProjectReference to MSTest.Analyzers.Package used
ReferenceOutputAssembly="false". NuGet pack omits the generated package
dependency for project references that do not reference the output assembly, so
the MSTest.Analyzers dependency was dropped entirely. Removing the attribute
makes pack emit `<dependency id="MSTest.Analyzers" include="...Analyzers,
BuildTransitive" />` at the co-built version while ExcludeAssets="compile;runtime"
still keeps the analyzer assembly out of this project's compile/runtime graph
(the analyzer package has IncludeBuildOutput=false, so there is no real assembly).
Verified by packing MSTest.TestFramework + MSTest.Analyzers locally and building a
consumer that references the package: it now reports `warning MSTEST0014` again.
net462 framework build remains clean (0 warnings) with the analyzers active.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 15:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 1

@Evangelink

This comment has been minimized.

Once MSTest.TestFramework correctly flows its MSTest.Analyzers dependency, the
analyzer projects' Microsoft.CodeAnalysis.* package references leaked
transitively through the framework's ProjectReference to in-repo consumers. That
forced Microsoft.CodeAnalysis.Common/CSharp 4.8.0 onto the source-generation test
projects (MSTest.SourceGeneration.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests),
which pin Roslyn 3.11.0, producing NU1608.
Roslyn is provided by the compiler host at analysis time and must never flow to
consumers, so mark Microsoft.CodeAnalysis.Analyzers/Common (MSTest.Analyzers) and
Microsoft.CodeAnalysis.CSharp.Workspaces (MSTest.Analyzers.CodeFixes) as
PrivateAssets="all". The produced MSTest.Analyzers package is unaffected
(SuppressDependenciesWhenPacking already yields zero dependencies and still ships
all analyzer assemblies).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

…ositive
The previous commit also marked Microsoft.CodeAnalysis.Analyzers PrivateAssets="all",
which changed the analyzer-authoring analyzer version that MSTest.Analyzers.CodeFixes
resolves and surfaced a known RS1024 false positive on
FlowTestContextCancellationTokenFixer.cs (the code already uses
SymbolEqualityComparer.Default). Only the Roslyn API package
(Microsoft.CodeAnalysis.Common) needs PrivateAssets to fix NU1608; revert the
attribute on Microsoft.CodeAnalysis.Analyzers so its pinned version keeps flowing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 17:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 1

…rift
MSTest.Analyzers.CodeFixes resolved Microsoft.CodeAnalysis.Analyzers transitively,
so a newer version (with a known RS1024 false positive on
new HashSet<ISymbol>(SymbolEqualityComparer.Default)) could win depending on the
restore graph. Add an explicit PrivateAssets="all" reference so it is always the
repo-pinned 5.3.0. Verified: CodeFixes restores 5.3.0 and builds clean (0 warnings).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

RunWithCooperativeCancellationAsync relied on new CancellationTokenSource(0)
having already cancelled its token at the IsCancellationRequested check, but the
0ms cancellation is scheduled on a timer rather than applied synchronously. On
fast machines (seen on net48 Release) the check ran before the timer fired, so
the action was invoked instead of failing immediately -- intermittently breaking
CancellationTimeoutHelperTests.RunWithCooperativeCancellationAsyncWhenTimeoutIsZeroReturnsFailureWithoutCallingAction.
Treat timeout == 0 as an immediate timeout explicitly. Production callers always
pass a positive configured timeout (Timeout.Infinite is -1, not 0), so behavior
is unchanged for them.
Verified: the full MSTestAdapter.PlatformServices.UnitTests net48 Release suite
(896 tests) passes, and the previously-failing test passes 6/6 runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 18:26

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 8/8 changed files
  • Comments generated: 1

@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9344

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 171 AIC · ⌖ 13.1 AIC · ⊞ 43.7K · [◷]( · )

@Evangelink
Amaury Levé (Evangelink) merged commit fd52133 into mainJun 22, 2026
33 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the evangelink/fix-main-mstest-package-downgrade branch June 22, 2026 20:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Evangelink@0101
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Fix main build broken by csproj-based MSTest packaging (#9259) - #9344

Merged
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade
Jun 22, 2026
Merged

Fix main build broken by csproj-based MSTest packaging (#9259)#9344
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented Jun 22, 2026

Copy link
Copy Markdown
Member

Problem

main is broken: the latest CI builds fail in the Build/Test tasks (Windows/Linux/macOS). The failures came in layers — fixing each revealed the next. This PR fixes all of them.

#StageSymptomRoot cause
1RestoreNU1605 downgrade of Microsoft.Testing.Platform.MSBuild#9259: adapter flows the locally-built platform MSBuild transitively, conflicting with the darc-pinned PackageReference
2CompileCS0234 missing MSTestAdapter.PlatformServices types#9259: adapter sets PrivateAssets="all" on PlatformServices, hiding it from in-repo consumers
3AfterSolutionBuildverify-nupkgs.ps1 file-count mismatch for MSTest.AotReflection.SourceGeneration#9338 made the PoC packable; not added to the expected-counts table
4Test (acceptance)AnalyzersShouldBeEnabled*, MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*#9259: MSTest.TestFramework was packed with empty dependency groups — the MSTest.Analyzers dependency was dropped, so analyzers no longer ran for consumers
5RestoreNU1608 Roslyn version conflict in the source-generation unit testsfixing #4 made the analyzer projects' Microsoft.CodeAnalysis.* refs leak transitively through the framework, clashing with the pinned Roslyn 3.11.0

The xlf drift that originally broke main was already fixed by #9339.

Fixes

  • test/Directory.Build.targets — under UseMSTestFromSource, reference Microsoft.Testing.Platform.MSBuild from source so both references resolve to the same version. (NU1605)
  • MSTest.IntegrationTests / MSTestAdapter.UnitTests — add a direct ProjectReference to MSTestAdapter.PlatformServices. (CS0234)
  • eng/verify-nupkgs.ps1 — add MSTest.AotReflection.SourceGeneration = 6. (verify-nupkgs)
  • TestFramework.Extensions.csproj — remove ReferenceOutputAssembly="false" from the MSTest.Analyzers.Package reference so pack emits <dependency id="MSTest.Analyzers" include="...Analyzers,BuildTransitive" /> at the co-built version. (analyzers)
  • MSTest.Analyzers / MSTest.Analyzers.CodeFixes — mark Microsoft.CodeAnalysis.* references PrivateAssets="all" so Roslyn (a compiler-host-provided dependency) never flows to consumers. (NU1608)

The adapter's intentional PrivateAssets settings are unchanged — the produced packages keep their historical dependency graphs.

Validation

  • Reproduced each failure on clean main (/p:OfficialBuildId=20260622.12, so the build version exceeds the darc pin) and confirmed each fix resolves it.
  • Built all affected projects (integration/adapter/source-gen/analyzer unit tests) — restore + build with 0 errors; the two source-gen test projects restore without NU1608.
  • Analyzers: packed MSTest.TestFramework + MSTest.Analyzers, built a consumer referencing the package → warning MSTEST0014 fires again. The MSTest.Analyzers package still ships all analyzer assemblies with zero dependencies; the framework net462 build stays clean with analyzers active.

Refs #9259, #9338.

PR #9259 (csproj packing, removing nuspec) introduced two regressions on
MSTest.TestAdapter's project references that broke the in-repo build once the
daily build number rolled past the dogfood pin:
1. NU1605 (restore): the adapter now ProjectReferences
Microsoft.Testing.Platform.MSBuild with PrivateAssets="none", flowing the
locally built platform-MSBuild (current build version) transitively to
in-repo consumers. Test projects with UseMSTestFromSource also PackageReference
the darc-pinned version, producing a package downgrade. Reference the platform
MSBuild from source when UseMSTestFromSource is set so both paths use the same
(project) version.
2. CS0234 (compile): the adapter now suppresses MSTestAdapter.PlatformServices as
a flowed dependency (PrivateAssets="all", correct for the produced package),
so in-repo consumers no longer see its (internals-visible) types. Reference
PlatformServices directly from MSTest.IntegrationTests and MSTestAdapter.UnitTests.
Validated by building the affected projects with /p:OfficialBuildId=20260622.12
(reproducing the CI build version > pin) -- restore and compile now succeed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 14:00

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the main branch build break caused by the csproj-based MSTest.TestAdapter packaging changes (#9259) by aligning in-repo test project references with the new PrivateAssets behavior and avoiding a restore-time NU1605 downgrade scenario when UseMSTestFromSource=true.

Changes:

  • Add direct ProjectReference to MSTestAdapter.PlatformServices for test projects that compile against its types, since it no longer flows transitively from MSTest.TestAdapter due to PrivateAssets="all".
  • Replace a Microsoft.Testing.Platform.MSBuildPackageReference with a source ProjectReference when UseMSTestFromSource=true to eliminate restore downgrades against the locally-built MSBuild integration.
  • Document the rationale inline in the affected project files / targets.
Show a summary per file
FileDescription
test/UnitTests/MSTestAdapter.UnitTests/MSTestAdapter.UnitTests.csprojAdds direct reference to MSTestAdapter.PlatformServices so unit tests can compile against its APIs despite PrivateAssets="all" on the adapter’s reference.
test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csprojAdds direct reference to MSTestAdapter.PlatformServices to restore compile-time access for integration test code using those types.
test/Directory.Build.targetsSwitches Microsoft.Testing.Platform.MSBuild from PackageReference to ProjectReference under UseMSTestFromSource=true to prevent NU1605 downgrade vs the transitively-referenced source-built project.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@Evangelink

This comment has been minimized.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.

Review notes (all dimensions)

Scope: 3 MSBuild project files changed (test/Directory.Build.targets, MSTest.IntegrationTests.csproj, MSTestAdapter.UnitTests.csproj). No C# runtime code touched.

DimensionResultNotes
1. Algorithmic Correctness✅ LGTMFix correctly targets the root cause: PrivateAssets="all" on the MSTestAdapter.PlatformServicesProjectReference in MSTest.TestAdapter prevents the assembly from flowing as a compile-time reference to consumers. Adding direct ProjectReference entries in both consuming test projects restores the reference. The PackageReference→ProjectReference change in Directory.Build.targets correctly resolves the NU1605 downgrade by ensuring both the direct reference and the transitively-flowed one resolve to the same locally-built project version.
2. Threading & ConcurrencyN/ANo C# code changed.
3. Security & IPC Contract SafetyN/ABuild config changes only.
4. Public API & Binary CompatibilityN/ANo public API touched.
5. Performance & AllocationsN/ANo runtime code changed.
6. Cross-TFM Compatibility✅ LGTMMSTestAdapter.PlatformServices is built for all TFMs that MSTestAdapter.UnitTests targets (net462;net48;net8.0;net9.0;WinUiMinimum), because MSTest.TestAdapter already includes them all. The single-TFM MSTest.IntegrationTests ($(NetFrameworkMinimum)) is also covered.
7. Resource & IDisposable ManagementN/ANo code changed.
8. Defensive Coding at BoundariesN/ANo code changed.
9. Localization & ResourcesN/ANo strings changed.
10. Test IsolationN/ANo test code changed.
11. Assertion QualityN/ANo test code changed.
12. Flakiness PatternsN/ANo test code changed.
13. Test Completeness & Coverage✅ LGTMThis is a build/restore fix with no new code paths; the author validated by reproducing the failure with /p:OfficialBuildId=20260622.12 and confirming all 6 affected projects restore and build clean. No additional tests needed.
14. Data-Driven Test CoverageN/ANo test code changed.
15. Code Structure & SimplificationN/ANo C# code changed.
16. Naming & ConventionsN/ANo C# code changed.
17. Documentation Accuracy✅ LGTMAll three added XML comments accurately explain why the reference is needed (link to #9259, explain the PrivateAssets="all" mechanism). Comments describe the intent, not just what the element does.
18. Analyzer & Code Fix QualityN/ANo src/Analyzers/ files changed.
19. IPC Wire CompatibilityN/ANo serialization code changed.
20. Build Infrastructure & Dependencies✅ LGTMThe PackageReference→ProjectReference swap is gated on UseMSTestFromSource='true' (matching the old condition), sits inside the existing EnableMSTestRunner OR UseInternalTestFramework outer ItemGroup, and references a first-party in-repo project that is always resolvable. The direct ProjectReference entries in the two test projects do not duplicate the assembly in output since MSBuild deduplicates project builds. InternalsVisibleTo coverage confirmed: MSTestAdapter.PlatformServices.csproj already declares InternalsVisibleTo for both Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests and MSTest.IntegrationTests. The four other UseMSTestFromSource=true projects omitted from the fix (MSTest.VstestConsoleWrapper.IntegrationTests, MSTest.Analyzers.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests, MSTest.SelfRealExamples.UnitTests) do not consume MSTestAdapter.PlatformServices internals directly and are not listed in its InternalsVisibleTo; they build fine without an explicit reference.
21. Scope & PR Discipline✅ LGTMSingle, tightly-scoped concern. Clear description with root-cause analysis, precise reproduction steps, and explicit validation. Refs #9259 appropriately.
22. PowerShell Scripting HygieneN/ANo .ps1 files changed.
MSBuild Authoring (supplemental)✅ LGTMCondition quoting is consistent with the repo style ('$(Prop)' == 'value'). The new ProjectReference has no PrivateAssets (defaults to all-assets-flow), which is the correct behavior for a test project reference. No DependsOn append issues, no stray whitespace, no condition ordering problems.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 22, 2026
…ounts
After the build progresses past the restore/compile fixes, verify-nupkgs.ps1
fails because MSTest.AotReflection.SourceGeneration (made packable as a
non-shipping PoC in #9338) is a 4.3.0 package not present in the expected
file-count table, so it is validated with an empty expected value. Add it with
its actual content count (6: [Content_Types].xml, Icon.png, .nuspec, the
analyzer dll, .psmdcp, .rels).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ency (#9259)
After the move to csproj-based packing (#9259), MSTest.TestFramework no longer
flowed the MSTest analyzers to consumers: the package was produced with empty
dependency groups, so projects referencing MSTest.TestFramework built with the
analyzers silently disabled (acceptance tests AnalyzersShouldBeEnabled*,
MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*
all failed).
Root cause: the ProjectReference to MSTest.Analyzers.Package used
ReferenceOutputAssembly="false". NuGet pack omits the generated package
dependency for project references that do not reference the output assembly, so
the MSTest.Analyzers dependency was dropped entirely. Removing the attribute
makes pack emit `<dependency id="MSTest.Analyzers" include="...Analyzers,
BuildTransitive" />` at the co-built version while ExcludeAssets="compile;runtime"
still keeps the analyzer assembly out of this project's compile/runtime graph
(the analyzer package has IncludeBuildOutput=false, so there is no real assembly).
Verified by packing MSTest.TestFramework + MSTest.Analyzers locally and building a
consumer that references the package: it now reports `warning MSTEST0014` again.
net462 framework build remains clean (0 warnings) with the analyzers active.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 15:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 1

@Evangelink

This comment has been minimized.

Once MSTest.TestFramework correctly flows its MSTest.Analyzers dependency, the
analyzer projects' Microsoft.CodeAnalysis.* package references leaked
transitively through the framework's ProjectReference to in-repo consumers. That
forced Microsoft.CodeAnalysis.Common/CSharp 4.8.0 onto the source-generation test
projects (MSTest.SourceGeneration.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests),
which pin Roslyn 3.11.0, producing NU1608.
Roslyn is provided by the compiler host at analysis time and must never flow to
consumers, so mark Microsoft.CodeAnalysis.Analyzers/Common (MSTest.Analyzers) and
Microsoft.CodeAnalysis.CSharp.Workspaces (MSTest.Analyzers.CodeFixes) as
PrivateAssets="all". The produced MSTest.Analyzers package is unaffected
(SuppressDependenciesWhenPacking already yields zero dependencies and still ships
all analyzer assemblies).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

…ositive
The previous commit also marked Microsoft.CodeAnalysis.Analyzers PrivateAssets="all",
which changed the analyzer-authoring analyzer version that MSTest.Analyzers.CodeFixes
resolves and surfaced a known RS1024 false positive on
FlowTestContextCancellationTokenFixer.cs (the code already uses
SymbolEqualityComparer.Default). Only the Roslyn API package
(Microsoft.CodeAnalysis.Common) needs PrivateAssets to fix NU1608; revert the
attribute on Microsoft.CodeAnalysis.Analyzers so its pinned version keeps flowing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 17:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 1

…rift
MSTest.Analyzers.CodeFixes resolved Microsoft.CodeAnalysis.Analyzers transitively,
so a newer version (with a known RS1024 false positive on
new HashSet<ISymbol>(SymbolEqualityComparer.Default)) could win depending on the
restore graph. Add an explicit PrivateAssets="all" reference so it is always the
repo-pinned 5.3.0. Verified: CodeFixes restores 5.3.0 and builds clean (0 warnings).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

RunWithCooperativeCancellationAsync relied on new CancellationTokenSource(0)
having already cancelled its token at the IsCancellationRequested check, but the
0ms cancellation is scheduled on a timer rather than applied synchronously. On
fast machines (seen on net48 Release) the check ran before the timer fired, so
the action was invoked instead of failing immediately -- intermittently breaking
CancellationTimeoutHelperTests.RunWithCooperativeCancellationAsyncWhenTimeoutIsZeroReturnsFailureWithoutCallingAction.
Treat timeout == 0 as an immediate timeout explicitly. Production callers always
pass a positive configured timeout (Timeout.Infinite is -1, not 0), so behavior
is unchanged for them.
Verified: the full MSTestAdapter.PlatformServices.UnitTests net48 Release suite
(896 tests) passes, and the previously-failing test passes 6/6 runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 18:26

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 8/8 changed files
  • Comments generated: 1

@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9344

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 171 AIC · ⌖ 13.1 AIC · ⊞ 43.7K · [◷]( · )

@Evangelink
Amaury Levé (Evangelink) merged commit fd52133 into mainJun 22, 2026
33 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the evangelink/fix-main-mstest-package-downgrade branch June 22, 2026 20:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Evangelink@0101
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Fix main build broken by csproj-based MSTest packaging (#9259) - #9344

Merged
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade
Jun 22, 2026
Merged

Fix main build broken by csproj-based MSTest packaging (#9259)#9344
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented Jun 22, 2026

Copy link
Copy Markdown
Member

Problem

main is broken: the latest CI builds fail in the Build/Test tasks (Windows/Linux/macOS). The failures came in layers — fixing each revealed the next. This PR fixes all of them.

#StageSymptomRoot cause
1RestoreNU1605 downgrade of Microsoft.Testing.Platform.MSBuild#9259: adapter flows the locally-built platform MSBuild transitively, conflicting with the darc-pinned PackageReference
2CompileCS0234 missing MSTestAdapter.PlatformServices types#9259: adapter sets PrivateAssets="all" on PlatformServices, hiding it from in-repo consumers
3AfterSolutionBuildverify-nupkgs.ps1 file-count mismatch for MSTest.AotReflection.SourceGeneration#9338 made the PoC packable; not added to the expected-counts table
4Test (acceptance)AnalyzersShouldBeEnabled*, MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*#9259: MSTest.TestFramework was packed with empty dependency groups — the MSTest.Analyzers dependency was dropped, so analyzers no longer ran for consumers
5RestoreNU1608 Roslyn version conflict in the source-generation unit testsfixing #4 made the analyzer projects' Microsoft.CodeAnalysis.* refs leak transitively through the framework, clashing with the pinned Roslyn 3.11.0

The xlf drift that originally broke main was already fixed by #9339.

Fixes

  • test/Directory.Build.targets — under UseMSTestFromSource, reference Microsoft.Testing.Platform.MSBuild from source so both references resolve to the same version. (NU1605)
  • MSTest.IntegrationTests / MSTestAdapter.UnitTests — add a direct ProjectReference to MSTestAdapter.PlatformServices. (CS0234)
  • eng/verify-nupkgs.ps1 — add MSTest.AotReflection.SourceGeneration = 6. (verify-nupkgs)
  • TestFramework.Extensions.csproj — remove ReferenceOutputAssembly="false" from the MSTest.Analyzers.Package reference so pack emits <dependency id="MSTest.Analyzers" include="...Analyzers,BuildTransitive" /> at the co-built version. (analyzers)
  • MSTest.Analyzers / MSTest.Analyzers.CodeFixes — mark Microsoft.CodeAnalysis.* references PrivateAssets="all" so Roslyn (a compiler-host-provided dependency) never flows to consumers. (NU1608)

The adapter's intentional PrivateAssets settings are unchanged — the produced packages keep their historical dependency graphs.

Validation

  • Reproduced each failure on clean main (/p:OfficialBuildId=20260622.12, so the build version exceeds the darc pin) and confirmed each fix resolves it.
  • Built all affected projects (integration/adapter/source-gen/analyzer unit tests) — restore + build with 0 errors; the two source-gen test projects restore without NU1608.
  • Analyzers: packed MSTest.TestFramework + MSTest.Analyzers, built a consumer referencing the package → warning MSTEST0014 fires again. The MSTest.Analyzers package still ships all analyzer assemblies with zero dependencies; the framework net462 build stays clean with analyzers active.

Refs #9259, #9338.

PR #9259 (csproj packing, removing nuspec) introduced two regressions on
MSTest.TestAdapter's project references that broke the in-repo build once the
daily build number rolled past the dogfood pin:
1. NU1605 (restore): the adapter now ProjectReferences
Microsoft.Testing.Platform.MSBuild with PrivateAssets="none", flowing the
locally built platform-MSBuild (current build version) transitively to
in-repo consumers. Test projects with UseMSTestFromSource also PackageReference
the darc-pinned version, producing a package downgrade. Reference the platform
MSBuild from source when UseMSTestFromSource is set so both paths use the same
(project) version.
2. CS0234 (compile): the adapter now suppresses MSTestAdapter.PlatformServices as
a flowed dependency (PrivateAssets="all", correct for the produced package),
so in-repo consumers no longer see its (internals-visible) types. Reference
PlatformServices directly from MSTest.IntegrationTests and MSTestAdapter.UnitTests.
Validated by building the affected projects with /p:OfficialBuildId=20260622.12
(reproducing the CI build version > pin) -- restore and compile now succeed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 14:00

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the main branch build break caused by the csproj-based MSTest.TestAdapter packaging changes (#9259) by aligning in-repo test project references with the new PrivateAssets behavior and avoiding a restore-time NU1605 downgrade scenario when UseMSTestFromSource=true.

Changes:

  • Add direct ProjectReference to MSTestAdapter.PlatformServices for test projects that compile against its types, since it no longer flows transitively from MSTest.TestAdapter due to PrivateAssets="all".
  • Replace a Microsoft.Testing.Platform.MSBuildPackageReference with a source ProjectReference when UseMSTestFromSource=true to eliminate restore downgrades against the locally-built MSBuild integration.
  • Document the rationale inline in the affected project files / targets.
Show a summary per file
FileDescription
test/UnitTests/MSTestAdapter.UnitTests/MSTestAdapter.UnitTests.csprojAdds direct reference to MSTestAdapter.PlatformServices so unit tests can compile against its APIs despite PrivateAssets="all" on the adapter’s reference.
test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csprojAdds direct reference to MSTestAdapter.PlatformServices to restore compile-time access for integration test code using those types.
test/Directory.Build.targetsSwitches Microsoft.Testing.Platform.MSBuild from PackageReference to ProjectReference under UseMSTestFromSource=true to prevent NU1605 downgrade vs the transitively-referenced source-built project.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@Evangelink

This comment has been minimized.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.

Review notes (all dimensions)

Scope: 3 MSBuild project files changed (test/Directory.Build.targets, MSTest.IntegrationTests.csproj, MSTestAdapter.UnitTests.csproj). No C# runtime code touched.

DimensionResultNotes
1. Algorithmic Correctness✅ LGTMFix correctly targets the root cause: PrivateAssets="all" on the MSTestAdapter.PlatformServicesProjectReference in MSTest.TestAdapter prevents the assembly from flowing as a compile-time reference to consumers. Adding direct ProjectReference entries in both consuming test projects restores the reference. The PackageReference→ProjectReference change in Directory.Build.targets correctly resolves the NU1605 downgrade by ensuring both the direct reference and the transitively-flowed one resolve to the same locally-built project version.
2. Threading & ConcurrencyN/ANo C# code changed.
3. Security & IPC Contract SafetyN/ABuild config changes only.
4. Public API & Binary CompatibilityN/ANo public API touched.
5. Performance & AllocationsN/ANo runtime code changed.
6. Cross-TFM Compatibility✅ LGTMMSTestAdapter.PlatformServices is built for all TFMs that MSTestAdapter.UnitTests targets (net462;net48;net8.0;net9.0;WinUiMinimum), because MSTest.TestAdapter already includes them all. The single-TFM MSTest.IntegrationTests ($(NetFrameworkMinimum)) is also covered.
7. Resource & IDisposable ManagementN/ANo code changed.
8. Defensive Coding at BoundariesN/ANo code changed.
9. Localization & ResourcesN/ANo strings changed.
10. Test IsolationN/ANo test code changed.
11. Assertion QualityN/ANo test code changed.
12. Flakiness PatternsN/ANo test code changed.
13. Test Completeness & Coverage✅ LGTMThis is a build/restore fix with no new code paths; the author validated by reproducing the failure with /p:OfficialBuildId=20260622.12 and confirming all 6 affected projects restore and build clean. No additional tests needed.
14. Data-Driven Test CoverageN/ANo test code changed.
15. Code Structure & SimplificationN/ANo C# code changed.
16. Naming & ConventionsN/ANo C# code changed.
17. Documentation Accuracy✅ LGTMAll three added XML comments accurately explain why the reference is needed (link to #9259, explain the PrivateAssets="all" mechanism). Comments describe the intent, not just what the element does.
18. Analyzer & Code Fix QualityN/ANo src/Analyzers/ files changed.
19. IPC Wire CompatibilityN/ANo serialization code changed.
20. Build Infrastructure & Dependencies✅ LGTMThe PackageReference→ProjectReference swap is gated on UseMSTestFromSource='true' (matching the old condition), sits inside the existing EnableMSTestRunner OR UseInternalTestFramework outer ItemGroup, and references a first-party in-repo project that is always resolvable. The direct ProjectReference entries in the two test projects do not duplicate the assembly in output since MSBuild deduplicates project builds. InternalsVisibleTo coverage confirmed: MSTestAdapter.PlatformServices.csproj already declares InternalsVisibleTo for both Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests and MSTest.IntegrationTests. The four other UseMSTestFromSource=true projects omitted from the fix (MSTest.VstestConsoleWrapper.IntegrationTests, MSTest.Analyzers.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests, MSTest.SelfRealExamples.UnitTests) do not consume MSTestAdapter.PlatformServices internals directly and are not listed in its InternalsVisibleTo; they build fine without an explicit reference.
21. Scope & PR Discipline✅ LGTMSingle, tightly-scoped concern. Clear description with root-cause analysis, precise reproduction steps, and explicit validation. Refs #9259 appropriately.
22. PowerShell Scripting HygieneN/ANo .ps1 files changed.
MSBuild Authoring (supplemental)✅ LGTMCondition quoting is consistent with the repo style ('$(Prop)' == 'value'). The new ProjectReference has no PrivateAssets (defaults to all-assets-flow), which is the correct behavior for a test project reference. No DependsOn append issues, no stray whitespace, no condition ordering problems.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 22, 2026
…ounts
After the build progresses past the restore/compile fixes, verify-nupkgs.ps1
fails because MSTest.AotReflection.SourceGeneration (made packable as a
non-shipping PoC in #9338) is a 4.3.0 package not present in the expected
file-count table, so it is validated with an empty expected value. Add it with
its actual content count (6: [Content_Types].xml, Icon.png, .nuspec, the
analyzer dll, .psmdcp, .rels).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ency (#9259)
After the move to csproj-based packing (#9259), MSTest.TestFramework no longer
flowed the MSTest analyzers to consumers: the package was produced with empty
dependency groups, so projects referencing MSTest.TestFramework built with the
analyzers silently disabled (acceptance tests AnalyzersShouldBeEnabled*,
MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*
all failed).
Root cause: the ProjectReference to MSTest.Analyzers.Package used
ReferenceOutputAssembly="false". NuGet pack omits the generated package
dependency for project references that do not reference the output assembly, so
the MSTest.Analyzers dependency was dropped entirely. Removing the attribute
makes pack emit `<dependency id="MSTest.Analyzers" include="...Analyzers,
BuildTransitive" />` at the co-built version while ExcludeAssets="compile;runtime"
still keeps the analyzer assembly out of this project's compile/runtime graph
(the analyzer package has IncludeBuildOutput=false, so there is no real assembly).
Verified by packing MSTest.TestFramework + MSTest.Analyzers locally and building a
consumer that references the package: it now reports `warning MSTEST0014` again.
net462 framework build remains clean (0 warnings) with the analyzers active.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 15:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 1

@Evangelink

This comment has been minimized.

Once MSTest.TestFramework correctly flows its MSTest.Analyzers dependency, the
analyzer projects' Microsoft.CodeAnalysis.* package references leaked
transitively through the framework's ProjectReference to in-repo consumers. That
forced Microsoft.CodeAnalysis.Common/CSharp 4.8.0 onto the source-generation test
projects (MSTest.SourceGeneration.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests),
which pin Roslyn 3.11.0, producing NU1608.
Roslyn is provided by the compiler host at analysis time and must never flow to
consumers, so mark Microsoft.CodeAnalysis.Analyzers/Common (MSTest.Analyzers) and
Microsoft.CodeAnalysis.CSharp.Workspaces (MSTest.Analyzers.CodeFixes) as
PrivateAssets="all". The produced MSTest.Analyzers package is unaffected
(SuppressDependenciesWhenPacking already yields zero dependencies and still ships
all analyzer assemblies).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

…ositive
The previous commit also marked Microsoft.CodeAnalysis.Analyzers PrivateAssets="all",
which changed the analyzer-authoring analyzer version that MSTest.Analyzers.CodeFixes
resolves and surfaced a known RS1024 false positive on
FlowTestContextCancellationTokenFixer.cs (the code already uses
SymbolEqualityComparer.Default). Only the Roslyn API package
(Microsoft.CodeAnalysis.Common) needs PrivateAssets to fix NU1608; revert the
attribute on Microsoft.CodeAnalysis.Analyzers so its pinned version keeps flowing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 17:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 1

…rift
MSTest.Analyzers.CodeFixes resolved Microsoft.CodeAnalysis.Analyzers transitively,
so a newer version (with a known RS1024 false positive on
new HashSet<ISymbol>(SymbolEqualityComparer.Default)) could win depending on the
restore graph. Add an explicit PrivateAssets="all" reference so it is always the
repo-pinned 5.3.0. Verified: CodeFixes restores 5.3.0 and builds clean (0 warnings).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

RunWithCooperativeCancellationAsync relied on new CancellationTokenSource(0)
having already cancelled its token at the IsCancellationRequested check, but the
0ms cancellation is scheduled on a timer rather than applied synchronously. On
fast machines (seen on net48 Release) the check ran before the timer fired, so
the action was invoked instead of failing immediately -- intermittently breaking
CancellationTimeoutHelperTests.RunWithCooperativeCancellationAsyncWhenTimeoutIsZeroReturnsFailureWithoutCallingAction.
Treat timeout == 0 as an immediate timeout explicitly. Production callers always
pass a positive configured timeout (Timeout.Infinite is -1, not 0), so behavior
is unchanged for them.
Verified: the full MSTestAdapter.PlatformServices.UnitTests net48 Release suite
(896 tests) passes, and the previously-failing test passes 6/6 runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 18:26

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 8/8 changed files
  • Comments generated: 1

@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9344

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 171 AIC · ⌖ 13.1 AIC · ⊞ 43.7K · [◷]( · )

@Evangelink
Amaury Levé (Evangelink) merged commit fd52133 into mainJun 22, 2026
33 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the evangelink/fix-main-mstest-package-downgrade branch June 22, 2026 20:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Evangelink@0101
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Fix main build broken by csproj-based MSTest packaging (#9259) - #9344

Merged
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade
Jun 22, 2026
Merged

Fix main build broken by csproj-based MSTest packaging (#9259)#9344
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented Jun 22, 2026

Copy link
Copy Markdown
Member

Problem

main is broken: the latest CI builds fail in the Build/Test tasks (Windows/Linux/macOS). The failures came in layers — fixing each revealed the next. This PR fixes all of them.

#StageSymptomRoot cause
1RestoreNU1605 downgrade of Microsoft.Testing.Platform.MSBuild#9259: adapter flows the locally-built platform MSBuild transitively, conflicting with the darc-pinned PackageReference
2CompileCS0234 missing MSTestAdapter.PlatformServices types#9259: adapter sets PrivateAssets="all" on PlatformServices, hiding it from in-repo consumers
3AfterSolutionBuildverify-nupkgs.ps1 file-count mismatch for MSTest.AotReflection.SourceGeneration#9338 made the PoC packable; not added to the expected-counts table
4Test (acceptance)AnalyzersShouldBeEnabled*, MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*#9259: MSTest.TestFramework was packed with empty dependency groups — the MSTest.Analyzers dependency was dropped, so analyzers no longer ran for consumers
5RestoreNU1608 Roslyn version conflict in the source-generation unit testsfixing #4 made the analyzer projects' Microsoft.CodeAnalysis.* refs leak transitively through the framework, clashing with the pinned Roslyn 3.11.0

The xlf drift that originally broke main was already fixed by #9339.

Fixes

  • test/Directory.Build.targets — under UseMSTestFromSource, reference Microsoft.Testing.Platform.MSBuild from source so both references resolve to the same version. (NU1605)
  • MSTest.IntegrationTests / MSTestAdapter.UnitTests — add a direct ProjectReference to MSTestAdapter.PlatformServices. (CS0234)
  • eng/verify-nupkgs.ps1 — add MSTest.AotReflection.SourceGeneration = 6. (verify-nupkgs)
  • TestFramework.Extensions.csproj — remove ReferenceOutputAssembly="false" from the MSTest.Analyzers.Package reference so pack emits <dependency id="MSTest.Analyzers" include="...Analyzers,BuildTransitive" /> at the co-built version. (analyzers)
  • MSTest.Analyzers / MSTest.Analyzers.CodeFixes — mark Microsoft.CodeAnalysis.* references PrivateAssets="all" so Roslyn (a compiler-host-provided dependency) never flows to consumers. (NU1608)

The adapter's intentional PrivateAssets settings are unchanged — the produced packages keep their historical dependency graphs.

Validation

  • Reproduced each failure on clean main (/p:OfficialBuildId=20260622.12, so the build version exceeds the darc pin) and confirmed each fix resolves it.
  • Built all affected projects (integration/adapter/source-gen/analyzer unit tests) — restore + build with 0 errors; the two source-gen test projects restore without NU1608.
  • Analyzers: packed MSTest.TestFramework + MSTest.Analyzers, built a consumer referencing the package → warning MSTEST0014 fires again. The MSTest.Analyzers package still ships all analyzer assemblies with zero dependencies; the framework net462 build stays clean with analyzers active.

Refs #9259, #9338.

PR #9259 (csproj packing, removing nuspec) introduced two regressions on
MSTest.TestAdapter's project references that broke the in-repo build once the
daily build number rolled past the dogfood pin:
1. NU1605 (restore): the adapter now ProjectReferences
Microsoft.Testing.Platform.MSBuild with PrivateAssets="none", flowing the
locally built platform-MSBuild (current build version) transitively to
in-repo consumers. Test projects with UseMSTestFromSource also PackageReference
the darc-pinned version, producing a package downgrade. Reference the platform
MSBuild from source when UseMSTestFromSource is set so both paths use the same
(project) version.
2. CS0234 (compile): the adapter now suppresses MSTestAdapter.PlatformServices as
a flowed dependency (PrivateAssets="all", correct for the produced package),
so in-repo consumers no longer see its (internals-visible) types. Reference
PlatformServices directly from MSTest.IntegrationTests and MSTestAdapter.UnitTests.
Validated by building the affected projects with /p:OfficialBuildId=20260622.12
(reproducing the CI build version > pin) -- restore and compile now succeed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 14:00

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the main branch build break caused by the csproj-based MSTest.TestAdapter packaging changes (#9259) by aligning in-repo test project references with the new PrivateAssets behavior and avoiding a restore-time NU1605 downgrade scenario when UseMSTestFromSource=true.

Changes:

  • Add direct ProjectReference to MSTestAdapter.PlatformServices for test projects that compile against its types, since it no longer flows transitively from MSTest.TestAdapter due to PrivateAssets="all".
  • Replace a Microsoft.Testing.Platform.MSBuildPackageReference with a source ProjectReference when UseMSTestFromSource=true to eliminate restore downgrades against the locally-built MSBuild integration.
  • Document the rationale inline in the affected project files / targets.
Show a summary per file
FileDescription
test/UnitTests/MSTestAdapter.UnitTests/MSTestAdapter.UnitTests.csprojAdds direct reference to MSTestAdapter.PlatformServices so unit tests can compile against its APIs despite PrivateAssets="all" on the adapter’s reference.
test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csprojAdds direct reference to MSTestAdapter.PlatformServices to restore compile-time access for integration test code using those types.
test/Directory.Build.targetsSwitches Microsoft.Testing.Platform.MSBuild from PackageReference to ProjectReference under UseMSTestFromSource=true to prevent NU1605 downgrade vs the transitively-referenced source-built project.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@Evangelink

This comment has been minimized.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.

Review notes (all dimensions)

Scope: 3 MSBuild project files changed (test/Directory.Build.targets, MSTest.IntegrationTests.csproj, MSTestAdapter.UnitTests.csproj). No C# runtime code touched.

DimensionResultNotes
1. Algorithmic Correctness✅ LGTMFix correctly targets the root cause: PrivateAssets="all" on the MSTestAdapter.PlatformServicesProjectReference in MSTest.TestAdapter prevents the assembly from flowing as a compile-time reference to consumers. Adding direct ProjectReference entries in both consuming test projects restores the reference. The PackageReference→ProjectReference change in Directory.Build.targets correctly resolves the NU1605 downgrade by ensuring both the direct reference and the transitively-flowed one resolve to the same locally-built project version.
2. Threading & ConcurrencyN/ANo C# code changed.
3. Security & IPC Contract SafetyN/ABuild config changes only.
4. Public API & Binary CompatibilityN/ANo public API touched.
5. Performance & AllocationsN/ANo runtime code changed.
6. Cross-TFM Compatibility✅ LGTMMSTestAdapter.PlatformServices is built for all TFMs that MSTestAdapter.UnitTests targets (net462;net48;net8.0;net9.0;WinUiMinimum), because MSTest.TestAdapter already includes them all. The single-TFM MSTest.IntegrationTests ($(NetFrameworkMinimum)) is also covered.
7. Resource & IDisposable ManagementN/ANo code changed.
8. Defensive Coding at BoundariesN/ANo code changed.
9. Localization & ResourcesN/ANo strings changed.
10. Test IsolationN/ANo test code changed.
11. Assertion QualityN/ANo test code changed.
12. Flakiness PatternsN/ANo test code changed.
13. Test Completeness & Coverage✅ LGTMThis is a build/restore fix with no new code paths; the author validated by reproducing the failure with /p:OfficialBuildId=20260622.12 and confirming all 6 affected projects restore and build clean. No additional tests needed.
14. Data-Driven Test CoverageN/ANo test code changed.
15. Code Structure & SimplificationN/ANo C# code changed.
16. Naming & ConventionsN/ANo C# code changed.
17. Documentation Accuracy✅ LGTMAll three added XML comments accurately explain why the reference is needed (link to #9259, explain the PrivateAssets="all" mechanism). Comments describe the intent, not just what the element does.
18. Analyzer & Code Fix QualityN/ANo src/Analyzers/ files changed.
19. IPC Wire CompatibilityN/ANo serialization code changed.
20. Build Infrastructure & Dependencies✅ LGTMThe PackageReference→ProjectReference swap is gated on UseMSTestFromSource='true' (matching the old condition), sits inside the existing EnableMSTestRunner OR UseInternalTestFramework outer ItemGroup, and references a first-party in-repo project that is always resolvable. The direct ProjectReference entries in the two test projects do not duplicate the assembly in output since MSBuild deduplicates project builds. InternalsVisibleTo coverage confirmed: MSTestAdapter.PlatformServices.csproj already declares InternalsVisibleTo for both Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests and MSTest.IntegrationTests. The four other UseMSTestFromSource=true projects omitted from the fix (MSTest.VstestConsoleWrapper.IntegrationTests, MSTest.Analyzers.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests, MSTest.SelfRealExamples.UnitTests) do not consume MSTestAdapter.PlatformServices internals directly and are not listed in its InternalsVisibleTo; they build fine without an explicit reference.
21. Scope & PR Discipline✅ LGTMSingle, tightly-scoped concern. Clear description with root-cause analysis, precise reproduction steps, and explicit validation. Refs #9259 appropriately.
22. PowerShell Scripting HygieneN/ANo .ps1 files changed.
MSBuild Authoring (supplemental)✅ LGTMCondition quoting is consistent with the repo style ('$(Prop)' == 'value'). The new ProjectReference has no PrivateAssets (defaults to all-assets-flow), which is the correct behavior for a test project reference. No DependsOn append issues, no stray whitespace, no condition ordering problems.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 22, 2026
…ounts
After the build progresses past the restore/compile fixes, verify-nupkgs.ps1
fails because MSTest.AotReflection.SourceGeneration (made packable as a
non-shipping PoC in #9338) is a 4.3.0 package not present in the expected
file-count table, so it is validated with an empty expected value. Add it with
its actual content count (6: [Content_Types].xml, Icon.png, .nuspec, the
analyzer dll, .psmdcp, .rels).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ency (#9259)
After the move to csproj-based packing (#9259), MSTest.TestFramework no longer
flowed the MSTest analyzers to consumers: the package was produced with empty
dependency groups, so projects referencing MSTest.TestFramework built with the
analyzers silently disabled (acceptance tests AnalyzersShouldBeEnabled*,
MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*
all failed).
Root cause: the ProjectReference to MSTest.Analyzers.Package used
ReferenceOutputAssembly="false". NuGet pack omits the generated package
dependency for project references that do not reference the output assembly, so
the MSTest.Analyzers dependency was dropped entirely. Removing the attribute
makes pack emit `<dependency id="MSTest.Analyzers" include="...Analyzers,
BuildTransitive" />` at the co-built version while ExcludeAssets="compile;runtime"
still keeps the analyzer assembly out of this project's compile/runtime graph
(the analyzer package has IncludeBuildOutput=false, so there is no real assembly).
Verified by packing MSTest.TestFramework + MSTest.Analyzers locally and building a
consumer that references the package: it now reports `warning MSTEST0014` again.
net462 framework build remains clean (0 warnings) with the analyzers active.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 15:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 1

@Evangelink

This comment has been minimized.

Once MSTest.TestFramework correctly flows its MSTest.Analyzers dependency, the
analyzer projects' Microsoft.CodeAnalysis.* package references leaked
transitively through the framework's ProjectReference to in-repo consumers. That
forced Microsoft.CodeAnalysis.Common/CSharp 4.8.0 onto the source-generation test
projects (MSTest.SourceGeneration.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests),
which pin Roslyn 3.11.0, producing NU1608.
Roslyn is provided by the compiler host at analysis time and must never flow to
consumers, so mark Microsoft.CodeAnalysis.Analyzers/Common (MSTest.Analyzers) and
Microsoft.CodeAnalysis.CSharp.Workspaces (MSTest.Analyzers.CodeFixes) as
PrivateAssets="all". The produced MSTest.Analyzers package is unaffected
(SuppressDependenciesWhenPacking already yields zero dependencies and still ships
all analyzer assemblies).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

…ositive
The previous commit also marked Microsoft.CodeAnalysis.Analyzers PrivateAssets="all",
which changed the analyzer-authoring analyzer version that MSTest.Analyzers.CodeFixes
resolves and surfaced a known RS1024 false positive on
FlowTestContextCancellationTokenFixer.cs (the code already uses
SymbolEqualityComparer.Default). Only the Roslyn API package
(Microsoft.CodeAnalysis.Common) needs PrivateAssets to fix NU1608; revert the
attribute on Microsoft.CodeAnalysis.Analyzers so its pinned version keeps flowing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 17:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 1

…rift
MSTest.Analyzers.CodeFixes resolved Microsoft.CodeAnalysis.Analyzers transitively,
so a newer version (with a known RS1024 false positive on
new HashSet<ISymbol>(SymbolEqualityComparer.Default)) could win depending on the
restore graph. Add an explicit PrivateAssets="all" reference so it is always the
repo-pinned 5.3.0. Verified: CodeFixes restores 5.3.0 and builds clean (0 warnings).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

RunWithCooperativeCancellationAsync relied on new CancellationTokenSource(0)
having already cancelled its token at the IsCancellationRequested check, but the
0ms cancellation is scheduled on a timer rather than applied synchronously. On
fast machines (seen on net48 Release) the check ran before the timer fired, so
the action was invoked instead of failing immediately -- intermittently breaking
CancellationTimeoutHelperTests.RunWithCooperativeCancellationAsyncWhenTimeoutIsZeroReturnsFailureWithoutCallingAction.
Treat timeout == 0 as an immediate timeout explicitly. Production callers always
pass a positive configured timeout (Timeout.Infinite is -1, not 0), so behavior
is unchanged for them.
Verified: the full MSTestAdapter.PlatformServices.UnitTests net48 Release suite
(896 tests) passes, and the previously-failing test passes 6/6 runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 18:26

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 8/8 changed files
  • Comments generated: 1

@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9344

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 171 AIC · ⌖ 13.1 AIC · ⊞ 43.7K · [◷]( · )

@Evangelink
Amaury Levé (Evangelink) merged commit fd52133 into mainJun 22, 2026
33 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the evangelink/fix-main-mstest-package-downgrade branch June 22, 2026 20:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Evangelink@0101
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Fix main build broken by csproj-based MSTest packaging (#9259) - #9344

Merged
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade
Jun 22, 2026
Merged

Fix main build broken by csproj-based MSTest packaging (#9259)#9344
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented Jun 22, 2026

Copy link
Copy Markdown
Member

Problem

main is broken: the latest CI builds fail in the Build/Test tasks (Windows/Linux/macOS). The failures came in layers — fixing each revealed the next. This PR fixes all of them.

#StageSymptomRoot cause
1RestoreNU1605 downgrade of Microsoft.Testing.Platform.MSBuild#9259: adapter flows the locally-built platform MSBuild transitively, conflicting with the darc-pinned PackageReference
2CompileCS0234 missing MSTestAdapter.PlatformServices types#9259: adapter sets PrivateAssets="all" on PlatformServices, hiding it from in-repo consumers
3AfterSolutionBuildverify-nupkgs.ps1 file-count mismatch for MSTest.AotReflection.SourceGeneration#9338 made the PoC packable; not added to the expected-counts table
4Test (acceptance)AnalyzersShouldBeEnabled*, MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*#9259: MSTest.TestFramework was packed with empty dependency groups — the MSTest.Analyzers dependency was dropped, so analyzers no longer ran for consumers
5RestoreNU1608 Roslyn version conflict in the source-generation unit testsfixing #4 made the analyzer projects' Microsoft.CodeAnalysis.* refs leak transitively through the framework, clashing with the pinned Roslyn 3.11.0

The xlf drift that originally broke main was already fixed by #9339.

Fixes

  • test/Directory.Build.targets — under UseMSTestFromSource, reference Microsoft.Testing.Platform.MSBuild from source so both references resolve to the same version. (NU1605)
  • MSTest.IntegrationTests / MSTestAdapter.UnitTests — add a direct ProjectReference to MSTestAdapter.PlatformServices. (CS0234)
  • eng/verify-nupkgs.ps1 — add MSTest.AotReflection.SourceGeneration = 6. (verify-nupkgs)
  • TestFramework.Extensions.csproj — remove ReferenceOutputAssembly="false" from the MSTest.Analyzers.Package reference so pack emits <dependency id="MSTest.Analyzers" include="...Analyzers,BuildTransitive" /> at the co-built version. (analyzers)
  • MSTest.Analyzers / MSTest.Analyzers.CodeFixes — mark Microsoft.CodeAnalysis.* references PrivateAssets="all" so Roslyn (a compiler-host-provided dependency) never flows to consumers. (NU1608)

The adapter's intentional PrivateAssets settings are unchanged — the produced packages keep their historical dependency graphs.

Validation

  • Reproduced each failure on clean main (/p:OfficialBuildId=20260622.12, so the build version exceeds the darc pin) and confirmed each fix resolves it.
  • Built all affected projects (integration/adapter/source-gen/analyzer unit tests) — restore + build with 0 errors; the two source-gen test projects restore without NU1608.
  • Analyzers: packed MSTest.TestFramework + MSTest.Analyzers, built a consumer referencing the package → warning MSTEST0014 fires again. The MSTest.Analyzers package still ships all analyzer assemblies with zero dependencies; the framework net462 build stays clean with analyzers active.

Refs #9259, #9338.

PR #9259 (csproj packing, removing nuspec) introduced two regressions on
MSTest.TestAdapter's project references that broke the in-repo build once the
daily build number rolled past the dogfood pin:
1. NU1605 (restore): the adapter now ProjectReferences
Microsoft.Testing.Platform.MSBuild with PrivateAssets="none", flowing the
locally built platform-MSBuild (current build version) transitively to
in-repo consumers. Test projects with UseMSTestFromSource also PackageReference
the darc-pinned version, producing a package downgrade. Reference the platform
MSBuild from source when UseMSTestFromSource is set so both paths use the same
(project) version.
2. CS0234 (compile): the adapter now suppresses MSTestAdapter.PlatformServices as
a flowed dependency (PrivateAssets="all", correct for the produced package),
so in-repo consumers no longer see its (internals-visible) types. Reference
PlatformServices directly from MSTest.IntegrationTests and MSTestAdapter.UnitTests.
Validated by building the affected projects with /p:OfficialBuildId=20260622.12
(reproducing the CI build version > pin) -- restore and compile now succeed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 14:00

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the main branch build break caused by the csproj-based MSTest.TestAdapter packaging changes (#9259) by aligning in-repo test project references with the new PrivateAssets behavior and avoiding a restore-time NU1605 downgrade scenario when UseMSTestFromSource=true.

Changes:

  • Add direct ProjectReference to MSTestAdapter.PlatformServices for test projects that compile against its types, since it no longer flows transitively from MSTest.TestAdapter due to PrivateAssets="all".
  • Replace a Microsoft.Testing.Platform.MSBuildPackageReference with a source ProjectReference when UseMSTestFromSource=true to eliminate restore downgrades against the locally-built MSBuild integration.
  • Document the rationale inline in the affected project files / targets.
Show a summary per file
FileDescription
test/UnitTests/MSTestAdapter.UnitTests/MSTestAdapter.UnitTests.csprojAdds direct reference to MSTestAdapter.PlatformServices so unit tests can compile against its APIs despite PrivateAssets="all" on the adapter’s reference.
test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csprojAdds direct reference to MSTestAdapter.PlatformServices to restore compile-time access for integration test code using those types.
test/Directory.Build.targetsSwitches Microsoft.Testing.Platform.MSBuild from PackageReference to ProjectReference under UseMSTestFromSource=true to prevent NU1605 downgrade vs the transitively-referenced source-built project.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@Evangelink

This comment has been minimized.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.

Review notes (all dimensions)

Scope: 3 MSBuild project files changed (test/Directory.Build.targets, MSTest.IntegrationTests.csproj, MSTestAdapter.UnitTests.csproj). No C# runtime code touched.

DimensionResultNotes
1. Algorithmic Correctness✅ LGTMFix correctly targets the root cause: PrivateAssets="all" on the MSTestAdapter.PlatformServicesProjectReference in MSTest.TestAdapter prevents the assembly from flowing as a compile-time reference to consumers. Adding direct ProjectReference entries in both consuming test projects restores the reference. The PackageReference→ProjectReference change in Directory.Build.targets correctly resolves the NU1605 downgrade by ensuring both the direct reference and the transitively-flowed one resolve to the same locally-built project version.
2. Threading & ConcurrencyN/ANo C# code changed.
3. Security & IPC Contract SafetyN/ABuild config changes only.
4. Public API & Binary CompatibilityN/ANo public API touched.
5. Performance & AllocationsN/ANo runtime code changed.
6. Cross-TFM Compatibility✅ LGTMMSTestAdapter.PlatformServices is built for all TFMs that MSTestAdapter.UnitTests targets (net462;net48;net8.0;net9.0;WinUiMinimum), because MSTest.TestAdapter already includes them all. The single-TFM MSTest.IntegrationTests ($(NetFrameworkMinimum)) is also covered.
7. Resource & IDisposable ManagementN/ANo code changed.
8. Defensive Coding at BoundariesN/ANo code changed.
9. Localization & ResourcesN/ANo strings changed.
10. Test IsolationN/ANo test code changed.
11. Assertion QualityN/ANo test code changed.
12. Flakiness PatternsN/ANo test code changed.
13. Test Completeness & Coverage✅ LGTMThis is a build/restore fix with no new code paths; the author validated by reproducing the failure with /p:OfficialBuildId=20260622.12 and confirming all 6 affected projects restore and build clean. No additional tests needed.
14. Data-Driven Test CoverageN/ANo test code changed.
15. Code Structure & SimplificationN/ANo C# code changed.
16. Naming & ConventionsN/ANo C# code changed.
17. Documentation Accuracy✅ LGTMAll three added XML comments accurately explain why the reference is needed (link to #9259, explain the PrivateAssets="all" mechanism). Comments describe the intent, not just what the element does.
18. Analyzer & Code Fix QualityN/ANo src/Analyzers/ files changed.
19. IPC Wire CompatibilityN/ANo serialization code changed.
20. Build Infrastructure & Dependencies✅ LGTMThe PackageReference→ProjectReference swap is gated on UseMSTestFromSource='true' (matching the old condition), sits inside the existing EnableMSTestRunner OR UseInternalTestFramework outer ItemGroup, and references a first-party in-repo project that is always resolvable. The direct ProjectReference entries in the two test projects do not duplicate the assembly in output since MSBuild deduplicates project builds. InternalsVisibleTo coverage confirmed: MSTestAdapter.PlatformServices.csproj already declares InternalsVisibleTo for both Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests and MSTest.IntegrationTests. The four other UseMSTestFromSource=true projects omitted from the fix (MSTest.VstestConsoleWrapper.IntegrationTests, MSTest.Analyzers.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests, MSTest.SelfRealExamples.UnitTests) do not consume MSTestAdapter.PlatformServices internals directly and are not listed in its InternalsVisibleTo; they build fine without an explicit reference.
21. Scope & PR Discipline✅ LGTMSingle, tightly-scoped concern. Clear description with root-cause analysis, precise reproduction steps, and explicit validation. Refs #9259 appropriately.
22. PowerShell Scripting HygieneN/ANo .ps1 files changed.
MSBuild Authoring (supplemental)✅ LGTMCondition quoting is consistent with the repo style ('$(Prop)' == 'value'). The new ProjectReference has no PrivateAssets (defaults to all-assets-flow), which is the correct behavior for a test project reference. No DependsOn append issues, no stray whitespace, no condition ordering problems.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 22, 2026
…ounts
After the build progresses past the restore/compile fixes, verify-nupkgs.ps1
fails because MSTest.AotReflection.SourceGeneration (made packable as a
non-shipping PoC in #9338) is a 4.3.0 package not present in the expected
file-count table, so it is validated with an empty expected value. Add it with
its actual content count (6: [Content_Types].xml, Icon.png, .nuspec, the
analyzer dll, .psmdcp, .rels).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ency (#9259)
After the move to csproj-based packing (#9259), MSTest.TestFramework no longer
flowed the MSTest analyzers to consumers: the package was produced with empty
dependency groups, so projects referencing MSTest.TestFramework built with the
analyzers silently disabled (acceptance tests AnalyzersShouldBeEnabled*,
MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*
all failed).
Root cause: the ProjectReference to MSTest.Analyzers.Package used
ReferenceOutputAssembly="false". NuGet pack omits the generated package
dependency for project references that do not reference the output assembly, so
the MSTest.Analyzers dependency was dropped entirely. Removing the attribute
makes pack emit `<dependency id="MSTest.Analyzers" include="...Analyzers,
BuildTransitive" />` at the co-built version while ExcludeAssets="compile;runtime"
still keeps the analyzer assembly out of this project's compile/runtime graph
(the analyzer package has IncludeBuildOutput=false, so there is no real assembly).
Verified by packing MSTest.TestFramework + MSTest.Analyzers locally and building a
consumer that references the package: it now reports `warning MSTEST0014` again.
net462 framework build remains clean (0 warnings) with the analyzers active.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 15:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 1

@Evangelink

This comment has been minimized.

Once MSTest.TestFramework correctly flows its MSTest.Analyzers dependency, the
analyzer projects' Microsoft.CodeAnalysis.* package references leaked
transitively through the framework's ProjectReference to in-repo consumers. That
forced Microsoft.CodeAnalysis.Common/CSharp 4.8.0 onto the source-generation test
projects (MSTest.SourceGeneration.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests),
which pin Roslyn 3.11.0, producing NU1608.
Roslyn is provided by the compiler host at analysis time and must never flow to
consumers, so mark Microsoft.CodeAnalysis.Analyzers/Common (MSTest.Analyzers) and
Microsoft.CodeAnalysis.CSharp.Workspaces (MSTest.Analyzers.CodeFixes) as
PrivateAssets="all". The produced MSTest.Analyzers package is unaffected
(SuppressDependenciesWhenPacking already yields zero dependencies and still ships
all analyzer assemblies).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

…ositive
The previous commit also marked Microsoft.CodeAnalysis.Analyzers PrivateAssets="all",
which changed the analyzer-authoring analyzer version that MSTest.Analyzers.CodeFixes
resolves and surfaced a known RS1024 false positive on
FlowTestContextCancellationTokenFixer.cs (the code already uses
SymbolEqualityComparer.Default). Only the Roslyn API package
(Microsoft.CodeAnalysis.Common) needs PrivateAssets to fix NU1608; revert the
attribute on Microsoft.CodeAnalysis.Analyzers so its pinned version keeps flowing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 17:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 1

…rift
MSTest.Analyzers.CodeFixes resolved Microsoft.CodeAnalysis.Analyzers transitively,
so a newer version (with a known RS1024 false positive on
new HashSet<ISymbol>(SymbolEqualityComparer.Default)) could win depending on the
restore graph. Add an explicit PrivateAssets="all" reference so it is always the
repo-pinned 5.3.0. Verified: CodeFixes restores 5.3.0 and builds clean (0 warnings).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

RunWithCooperativeCancellationAsync relied on new CancellationTokenSource(0)
having already cancelled its token at the IsCancellationRequested check, but the
0ms cancellation is scheduled on a timer rather than applied synchronously. On
fast machines (seen on net48 Release) the check ran before the timer fired, so
the action was invoked instead of failing immediately -- intermittently breaking
CancellationTimeoutHelperTests.RunWithCooperativeCancellationAsyncWhenTimeoutIsZeroReturnsFailureWithoutCallingAction.
Treat timeout == 0 as an immediate timeout explicitly. Production callers always
pass a positive configured timeout (Timeout.Infinite is -1, not 0), so behavior
is unchanged for them.
Verified: the full MSTestAdapter.PlatformServices.UnitTests net48 Release suite
(896 tests) passes, and the previously-failing test passes 6/6 runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 18:26

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 8/8 changed files
  • Comments generated: 1

@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9344

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 171 AIC · ⌖ 13.1 AIC · ⊞ 43.7K · [◷]( · )

@Evangelink
Amaury Levé (Evangelink) merged commit fd52133 into mainJun 22, 2026
33 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the evangelink/fix-main-mstest-package-downgrade branch June 22, 2026 20:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Evangelink@0101
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Fix main build broken by csproj-based MSTest packaging (#9259) - #9344

Merged
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade
Jun 22, 2026
Merged

Fix main build broken by csproj-based MSTest packaging (#9259)#9344
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented Jun 22, 2026

Copy link
Copy Markdown
Member

Problem

main is broken: the latest CI builds fail in the Build/Test tasks (Windows/Linux/macOS). The failures came in layers — fixing each revealed the next. This PR fixes all of them.

#StageSymptomRoot cause
1RestoreNU1605 downgrade of Microsoft.Testing.Platform.MSBuild#9259: adapter flows the locally-built platform MSBuild transitively, conflicting with the darc-pinned PackageReference
2CompileCS0234 missing MSTestAdapter.PlatformServices types#9259: adapter sets PrivateAssets="all" on PlatformServices, hiding it from in-repo consumers
3AfterSolutionBuildverify-nupkgs.ps1 file-count mismatch for MSTest.AotReflection.SourceGeneration#9338 made the PoC packable; not added to the expected-counts table
4Test (acceptance)AnalyzersShouldBeEnabled*, MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*#9259: MSTest.TestFramework was packed with empty dependency groups — the MSTest.Analyzers dependency was dropped, so analyzers no longer ran for consumers
5RestoreNU1608 Roslyn version conflict in the source-generation unit testsfixing #4 made the analyzer projects' Microsoft.CodeAnalysis.* refs leak transitively through the framework, clashing with the pinned Roslyn 3.11.0

The xlf drift that originally broke main was already fixed by #9339.

Fixes

  • test/Directory.Build.targets — under UseMSTestFromSource, reference Microsoft.Testing.Platform.MSBuild from source so both references resolve to the same version. (NU1605)
  • MSTest.IntegrationTests / MSTestAdapter.UnitTests — add a direct ProjectReference to MSTestAdapter.PlatformServices. (CS0234)
  • eng/verify-nupkgs.ps1 — add MSTest.AotReflection.SourceGeneration = 6. (verify-nupkgs)
  • TestFramework.Extensions.csproj — remove ReferenceOutputAssembly="false" from the MSTest.Analyzers.Package reference so pack emits <dependency id="MSTest.Analyzers" include="...Analyzers,BuildTransitive" /> at the co-built version. (analyzers)
  • MSTest.Analyzers / MSTest.Analyzers.CodeFixes — mark Microsoft.CodeAnalysis.* references PrivateAssets="all" so Roslyn (a compiler-host-provided dependency) never flows to consumers. (NU1608)

The adapter's intentional PrivateAssets settings are unchanged — the produced packages keep their historical dependency graphs.

Validation

  • Reproduced each failure on clean main (/p:OfficialBuildId=20260622.12, so the build version exceeds the darc pin) and confirmed each fix resolves it.
  • Built all affected projects (integration/adapter/source-gen/analyzer unit tests) — restore + build with 0 errors; the two source-gen test projects restore without NU1608.
  • Analyzers: packed MSTest.TestFramework + MSTest.Analyzers, built a consumer referencing the package → warning MSTEST0014 fires again. The MSTest.Analyzers package still ships all analyzer assemblies with zero dependencies; the framework net462 build stays clean with analyzers active.

Refs #9259, #9338.

PR #9259 (csproj packing, removing nuspec) introduced two regressions on
MSTest.TestAdapter's project references that broke the in-repo build once the
daily build number rolled past the dogfood pin:
1. NU1605 (restore): the adapter now ProjectReferences
Microsoft.Testing.Platform.MSBuild with PrivateAssets="none", flowing the
locally built platform-MSBuild (current build version) transitively to
in-repo consumers. Test projects with UseMSTestFromSource also PackageReference
the darc-pinned version, producing a package downgrade. Reference the platform
MSBuild from source when UseMSTestFromSource is set so both paths use the same
(project) version.
2. CS0234 (compile): the adapter now suppresses MSTestAdapter.PlatformServices as
a flowed dependency (PrivateAssets="all", correct for the produced package),
so in-repo consumers no longer see its (internals-visible) types. Reference
PlatformServices directly from MSTest.IntegrationTests and MSTestAdapter.UnitTests.
Validated by building the affected projects with /p:OfficialBuildId=20260622.12
(reproducing the CI build version > pin) -- restore and compile now succeed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 14:00

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the main branch build break caused by the csproj-based MSTest.TestAdapter packaging changes (#9259) by aligning in-repo test project references with the new PrivateAssets behavior and avoiding a restore-time NU1605 downgrade scenario when UseMSTestFromSource=true.

Changes:

  • Add direct ProjectReference to MSTestAdapter.PlatformServices for test projects that compile against its types, since it no longer flows transitively from MSTest.TestAdapter due to PrivateAssets="all".
  • Replace a Microsoft.Testing.Platform.MSBuildPackageReference with a source ProjectReference when UseMSTestFromSource=true to eliminate restore downgrades against the locally-built MSBuild integration.
  • Document the rationale inline in the affected project files / targets.
Show a summary per file
FileDescription
test/UnitTests/MSTestAdapter.UnitTests/MSTestAdapter.UnitTests.csprojAdds direct reference to MSTestAdapter.PlatformServices so unit tests can compile against its APIs despite PrivateAssets="all" on the adapter’s reference.
test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csprojAdds direct reference to MSTestAdapter.PlatformServices to restore compile-time access for integration test code using those types.
test/Directory.Build.targetsSwitches Microsoft.Testing.Platform.MSBuild from PackageReference to ProjectReference under UseMSTestFromSource=true to prevent NU1605 downgrade vs the transitively-referenced source-built project.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@Evangelink

This comment has been minimized.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.

Review notes (all dimensions)

Scope: 3 MSBuild project files changed (test/Directory.Build.targets, MSTest.IntegrationTests.csproj, MSTestAdapter.UnitTests.csproj). No C# runtime code touched.

DimensionResultNotes
1. Algorithmic Correctness✅ LGTMFix correctly targets the root cause: PrivateAssets="all" on the MSTestAdapter.PlatformServicesProjectReference in MSTest.TestAdapter prevents the assembly from flowing as a compile-time reference to consumers. Adding direct ProjectReference entries in both consuming test projects restores the reference. The PackageReference→ProjectReference change in Directory.Build.targets correctly resolves the NU1605 downgrade by ensuring both the direct reference and the transitively-flowed one resolve to the same locally-built project version.
2. Threading & ConcurrencyN/ANo C# code changed.
3. Security & IPC Contract SafetyN/ABuild config changes only.
4. Public API & Binary CompatibilityN/ANo public API touched.
5. Performance & AllocationsN/ANo runtime code changed.
6. Cross-TFM Compatibility✅ LGTMMSTestAdapter.PlatformServices is built for all TFMs that MSTestAdapter.UnitTests targets (net462;net48;net8.0;net9.0;WinUiMinimum), because MSTest.TestAdapter already includes them all. The single-TFM MSTest.IntegrationTests ($(NetFrameworkMinimum)) is also covered.
7. Resource & IDisposable ManagementN/ANo code changed.
8. Defensive Coding at BoundariesN/ANo code changed.
9. Localization & ResourcesN/ANo strings changed.
10. Test IsolationN/ANo test code changed.
11. Assertion QualityN/ANo test code changed.
12. Flakiness PatternsN/ANo test code changed.
13. Test Completeness & Coverage✅ LGTMThis is a build/restore fix with no new code paths; the author validated by reproducing the failure with /p:OfficialBuildId=20260622.12 and confirming all 6 affected projects restore and build clean. No additional tests needed.
14. Data-Driven Test CoverageN/ANo test code changed.
15. Code Structure & SimplificationN/ANo C# code changed.
16. Naming & ConventionsN/ANo C# code changed.
17. Documentation Accuracy✅ LGTMAll three added XML comments accurately explain why the reference is needed (link to #9259, explain the PrivateAssets="all" mechanism). Comments describe the intent, not just what the element does.
18. Analyzer & Code Fix QualityN/ANo src/Analyzers/ files changed.
19. IPC Wire CompatibilityN/ANo serialization code changed.
20. Build Infrastructure & Dependencies✅ LGTMThe PackageReference→ProjectReference swap is gated on UseMSTestFromSource='true' (matching the old condition), sits inside the existing EnableMSTestRunner OR UseInternalTestFramework outer ItemGroup, and references a first-party in-repo project that is always resolvable. The direct ProjectReference entries in the two test projects do not duplicate the assembly in output since MSBuild deduplicates project builds. InternalsVisibleTo coverage confirmed: MSTestAdapter.PlatformServices.csproj already declares InternalsVisibleTo for both Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests and MSTest.IntegrationTests. The four other UseMSTestFromSource=true projects omitted from the fix (MSTest.VstestConsoleWrapper.IntegrationTests, MSTest.Analyzers.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests, MSTest.SelfRealExamples.UnitTests) do not consume MSTestAdapter.PlatformServices internals directly and are not listed in its InternalsVisibleTo; they build fine without an explicit reference.
21. Scope & PR Discipline✅ LGTMSingle, tightly-scoped concern. Clear description with root-cause analysis, precise reproduction steps, and explicit validation. Refs #9259 appropriately.
22. PowerShell Scripting HygieneN/ANo .ps1 files changed.
MSBuild Authoring (supplemental)✅ LGTMCondition quoting is consistent with the repo style ('$(Prop)' == 'value'). The new ProjectReference has no PrivateAssets (defaults to all-assets-flow), which is the correct behavior for a test project reference. No DependsOn append issues, no stray whitespace, no condition ordering problems.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 22, 2026
…ounts
After the build progresses past the restore/compile fixes, verify-nupkgs.ps1
fails because MSTest.AotReflection.SourceGeneration (made packable as a
non-shipping PoC in #9338) is a 4.3.0 package not present in the expected
file-count table, so it is validated with an empty expected value. Add it with
its actual content count (6: [Content_Types].xml, Icon.png, .nuspec, the
analyzer dll, .psmdcp, .rels).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ency (#9259)
After the move to csproj-based packing (#9259), MSTest.TestFramework no longer
flowed the MSTest analyzers to consumers: the package was produced with empty
dependency groups, so projects referencing MSTest.TestFramework built with the
analyzers silently disabled (acceptance tests AnalyzersShouldBeEnabled*,
MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*
all failed).
Root cause: the ProjectReference to MSTest.Analyzers.Package used
ReferenceOutputAssembly="false". NuGet pack omits the generated package
dependency for project references that do not reference the output assembly, so
the MSTest.Analyzers dependency was dropped entirely. Removing the attribute
makes pack emit `<dependency id="MSTest.Analyzers" include="...Analyzers,
BuildTransitive" />` at the co-built version while ExcludeAssets="compile;runtime"
still keeps the analyzer assembly out of this project's compile/runtime graph
(the analyzer package has IncludeBuildOutput=false, so there is no real assembly).
Verified by packing MSTest.TestFramework + MSTest.Analyzers locally and building a
consumer that references the package: it now reports `warning MSTEST0014` again.
net462 framework build remains clean (0 warnings) with the analyzers active.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 15:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 1

@Evangelink

This comment has been minimized.

Once MSTest.TestFramework correctly flows its MSTest.Analyzers dependency, the
analyzer projects' Microsoft.CodeAnalysis.* package references leaked
transitively through the framework's ProjectReference to in-repo consumers. That
forced Microsoft.CodeAnalysis.Common/CSharp 4.8.0 onto the source-generation test
projects (MSTest.SourceGeneration.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests),
which pin Roslyn 3.11.0, producing NU1608.
Roslyn is provided by the compiler host at analysis time and must never flow to
consumers, so mark Microsoft.CodeAnalysis.Analyzers/Common (MSTest.Analyzers) and
Microsoft.CodeAnalysis.CSharp.Workspaces (MSTest.Analyzers.CodeFixes) as
PrivateAssets="all". The produced MSTest.Analyzers package is unaffected
(SuppressDependenciesWhenPacking already yields zero dependencies and still ships
all analyzer assemblies).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

…ositive
The previous commit also marked Microsoft.CodeAnalysis.Analyzers PrivateAssets="all",
which changed the analyzer-authoring analyzer version that MSTest.Analyzers.CodeFixes
resolves and surfaced a known RS1024 false positive on
FlowTestContextCancellationTokenFixer.cs (the code already uses
SymbolEqualityComparer.Default). Only the Roslyn API package
(Microsoft.CodeAnalysis.Common) needs PrivateAssets to fix NU1608; revert the
attribute on Microsoft.CodeAnalysis.Analyzers so its pinned version keeps flowing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 17:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 1

…rift
MSTest.Analyzers.CodeFixes resolved Microsoft.CodeAnalysis.Analyzers transitively,
so a newer version (with a known RS1024 false positive on
new HashSet<ISymbol>(SymbolEqualityComparer.Default)) could win depending on the
restore graph. Add an explicit PrivateAssets="all" reference so it is always the
repo-pinned 5.3.0. Verified: CodeFixes restores 5.3.0 and builds clean (0 warnings).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

RunWithCooperativeCancellationAsync relied on new CancellationTokenSource(0)
having already cancelled its token at the IsCancellationRequested check, but the
0ms cancellation is scheduled on a timer rather than applied synchronously. On
fast machines (seen on net48 Release) the check ran before the timer fired, so
the action was invoked instead of failing immediately -- intermittently breaking
CancellationTimeoutHelperTests.RunWithCooperativeCancellationAsyncWhenTimeoutIsZeroReturnsFailureWithoutCallingAction.
Treat timeout == 0 as an immediate timeout explicitly. Production callers always
pass a positive configured timeout (Timeout.Infinite is -1, not 0), so behavior
is unchanged for them.
Verified: the full MSTestAdapter.PlatformServices.UnitTests net48 Release suite
(896 tests) passes, and the previously-failing test passes 6/6 runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 18:26

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 8/8 changed files
  • Comments generated: 1

@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9344

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 171 AIC · ⌖ 13.1 AIC · ⊞ 43.7K · [◷]( · )

@Evangelink
Amaury Levé (Evangelink) merged commit fd52133 into mainJun 22, 2026
33 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the evangelink/fix-main-mstest-package-downgrade branch June 22, 2026 20:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Evangelink@0101
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Fix main build broken by csproj-based MSTest packaging (#9259) - #9344

Merged
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade
Jun 22, 2026
Merged

Fix main build broken by csproj-based MSTest packaging (#9259)#9344
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented Jun 22, 2026

Copy link
Copy Markdown
Member

Problem

main is broken: the latest CI builds fail in the Build/Test tasks (Windows/Linux/macOS). The failures came in layers — fixing each revealed the next. This PR fixes all of them.

#StageSymptomRoot cause
1RestoreNU1605 downgrade of Microsoft.Testing.Platform.MSBuild#9259: adapter flows the locally-built platform MSBuild transitively, conflicting with the darc-pinned PackageReference
2CompileCS0234 missing MSTestAdapter.PlatformServices types#9259: adapter sets PrivateAssets="all" on PlatformServices, hiding it from in-repo consumers
3AfterSolutionBuildverify-nupkgs.ps1 file-count mismatch for MSTest.AotReflection.SourceGeneration#9338 made the PoC packable; not added to the expected-counts table
4Test (acceptance)AnalyzersShouldBeEnabled*, MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*#9259: MSTest.TestFramework was packed with empty dependency groups — the MSTest.Analyzers dependency was dropped, so analyzers no longer ran for consumers
5RestoreNU1608 Roslyn version conflict in the source-generation unit testsfixing #4 made the analyzer projects' Microsoft.CodeAnalysis.* refs leak transitively through the framework, clashing with the pinned Roslyn 3.11.0

The xlf drift that originally broke main was already fixed by #9339.

Fixes

  • test/Directory.Build.targets — under UseMSTestFromSource, reference Microsoft.Testing.Platform.MSBuild from source so both references resolve to the same version. (NU1605)
  • MSTest.IntegrationTests / MSTestAdapter.UnitTests — add a direct ProjectReference to MSTestAdapter.PlatformServices. (CS0234)
  • eng/verify-nupkgs.ps1 — add MSTest.AotReflection.SourceGeneration = 6. (verify-nupkgs)
  • TestFramework.Extensions.csproj — remove ReferenceOutputAssembly="false" from the MSTest.Analyzers.Package reference so pack emits <dependency id="MSTest.Analyzers" include="...Analyzers,BuildTransitive" /> at the co-built version. (analyzers)
  • MSTest.Analyzers / MSTest.Analyzers.CodeFixes — mark Microsoft.CodeAnalysis.* references PrivateAssets="all" so Roslyn (a compiler-host-provided dependency) never flows to consumers. (NU1608)

The adapter's intentional PrivateAssets settings are unchanged — the produced packages keep their historical dependency graphs.

Validation

  • Reproduced each failure on clean main (/p:OfficialBuildId=20260622.12, so the build version exceeds the darc pin) and confirmed each fix resolves it.
  • Built all affected projects (integration/adapter/source-gen/analyzer unit tests) — restore + build with 0 errors; the two source-gen test projects restore without NU1608.
  • Analyzers: packed MSTest.TestFramework + MSTest.Analyzers, built a consumer referencing the package → warning MSTEST0014 fires again. The MSTest.Analyzers package still ships all analyzer assemblies with zero dependencies; the framework net462 build stays clean with analyzers active.

Refs #9259, #9338.

PR #9259 (csproj packing, removing nuspec) introduced two regressions on
MSTest.TestAdapter's project references that broke the in-repo build once the
daily build number rolled past the dogfood pin:
1. NU1605 (restore): the adapter now ProjectReferences
Microsoft.Testing.Platform.MSBuild with PrivateAssets="none", flowing the
locally built platform-MSBuild (current build version) transitively to
in-repo consumers. Test projects with UseMSTestFromSource also PackageReference
the darc-pinned version, producing a package downgrade. Reference the platform
MSBuild from source when UseMSTestFromSource is set so both paths use the same
(project) version.
2. CS0234 (compile): the adapter now suppresses MSTestAdapter.PlatformServices as
a flowed dependency (PrivateAssets="all", correct for the produced package),
so in-repo consumers no longer see its (internals-visible) types. Reference
PlatformServices directly from MSTest.IntegrationTests and MSTestAdapter.UnitTests.
Validated by building the affected projects with /p:OfficialBuildId=20260622.12
(reproducing the CI build version > pin) -- restore and compile now succeed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 14:00

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the main branch build break caused by the csproj-based MSTest.TestAdapter packaging changes (#9259) by aligning in-repo test project references with the new PrivateAssets behavior and avoiding a restore-time NU1605 downgrade scenario when UseMSTestFromSource=true.

Changes:

  • Add direct ProjectReference to MSTestAdapter.PlatformServices for test projects that compile against its types, since it no longer flows transitively from MSTest.TestAdapter due to PrivateAssets="all".
  • Replace a Microsoft.Testing.Platform.MSBuildPackageReference with a source ProjectReference when UseMSTestFromSource=true to eliminate restore downgrades against the locally-built MSBuild integration.
  • Document the rationale inline in the affected project files / targets.
Show a summary per file
FileDescription
test/UnitTests/MSTestAdapter.UnitTests/MSTestAdapter.UnitTests.csprojAdds direct reference to MSTestAdapter.PlatformServices so unit tests can compile against its APIs despite PrivateAssets="all" on the adapter’s reference.
test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csprojAdds direct reference to MSTestAdapter.PlatformServices to restore compile-time access for integration test code using those types.
test/Directory.Build.targetsSwitches Microsoft.Testing.Platform.MSBuild from PackageReference to ProjectReference under UseMSTestFromSource=true to prevent NU1605 downgrade vs the transitively-referenced source-built project.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@Evangelink

This comment has been minimized.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.

Review notes (all dimensions)

Scope: 3 MSBuild project files changed (test/Directory.Build.targets, MSTest.IntegrationTests.csproj, MSTestAdapter.UnitTests.csproj). No C# runtime code touched.

DimensionResultNotes
1. Algorithmic Correctness✅ LGTMFix correctly targets the root cause: PrivateAssets="all" on the MSTestAdapter.PlatformServicesProjectReference in MSTest.TestAdapter prevents the assembly from flowing as a compile-time reference to consumers. Adding direct ProjectReference entries in both consuming test projects restores the reference. The PackageReference→ProjectReference change in Directory.Build.targets correctly resolves the NU1605 downgrade by ensuring both the direct reference and the transitively-flowed one resolve to the same locally-built project version.
2. Threading & ConcurrencyN/ANo C# code changed.
3. Security & IPC Contract SafetyN/ABuild config changes only.
4. Public API & Binary CompatibilityN/ANo public API touched.
5. Performance & AllocationsN/ANo runtime code changed.
6. Cross-TFM Compatibility✅ LGTMMSTestAdapter.PlatformServices is built for all TFMs that MSTestAdapter.UnitTests targets (net462;net48;net8.0;net9.0;WinUiMinimum), because MSTest.TestAdapter already includes them all. The single-TFM MSTest.IntegrationTests ($(NetFrameworkMinimum)) is also covered.
7. Resource & IDisposable ManagementN/ANo code changed.
8. Defensive Coding at BoundariesN/ANo code changed.
9. Localization & ResourcesN/ANo strings changed.
10. Test IsolationN/ANo test code changed.
11. Assertion QualityN/ANo test code changed.
12. Flakiness PatternsN/ANo test code changed.
13. Test Completeness & Coverage✅ LGTMThis is a build/restore fix with no new code paths; the author validated by reproducing the failure with /p:OfficialBuildId=20260622.12 and confirming all 6 affected projects restore and build clean. No additional tests needed.
14. Data-Driven Test CoverageN/ANo test code changed.
15. Code Structure & SimplificationN/ANo C# code changed.
16. Naming & ConventionsN/ANo C# code changed.
17. Documentation Accuracy✅ LGTMAll three added XML comments accurately explain why the reference is needed (link to #9259, explain the PrivateAssets="all" mechanism). Comments describe the intent, not just what the element does.
18. Analyzer & Code Fix QualityN/ANo src/Analyzers/ files changed.
19. IPC Wire CompatibilityN/ANo serialization code changed.
20. Build Infrastructure & Dependencies✅ LGTMThe PackageReference→ProjectReference swap is gated on UseMSTestFromSource='true' (matching the old condition), sits inside the existing EnableMSTestRunner OR UseInternalTestFramework outer ItemGroup, and references a first-party in-repo project that is always resolvable. The direct ProjectReference entries in the two test projects do not duplicate the assembly in output since MSBuild deduplicates project builds. InternalsVisibleTo coverage confirmed: MSTestAdapter.PlatformServices.csproj already declares InternalsVisibleTo for both Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests and MSTest.IntegrationTests. The four other UseMSTestFromSource=true projects omitted from the fix (MSTest.VstestConsoleWrapper.IntegrationTests, MSTest.Analyzers.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests, MSTest.SelfRealExamples.UnitTests) do not consume MSTestAdapter.PlatformServices internals directly and are not listed in its InternalsVisibleTo; they build fine without an explicit reference.
21. Scope & PR Discipline✅ LGTMSingle, tightly-scoped concern. Clear description with root-cause analysis, precise reproduction steps, and explicit validation. Refs #9259 appropriately.
22. PowerShell Scripting HygieneN/ANo .ps1 files changed.
MSBuild Authoring (supplemental)✅ LGTMCondition quoting is consistent with the repo style ('$(Prop)' == 'value'). The new ProjectReference has no PrivateAssets (defaults to all-assets-flow), which is the correct behavior for a test project reference. No DependsOn append issues, no stray whitespace, no condition ordering problems.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 22, 2026
…ounts
After the build progresses past the restore/compile fixes, verify-nupkgs.ps1
fails because MSTest.AotReflection.SourceGeneration (made packable as a
non-shipping PoC in #9338) is a 4.3.0 package not present in the expected
file-count table, so it is validated with an empty expected value. Add it with
its actual content count (6: [Content_Types].xml, Icon.png, .nuspec, the
analyzer dll, .psmdcp, .rels).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ency (#9259)
After the move to csproj-based packing (#9259), MSTest.TestFramework no longer
flowed the MSTest analyzers to consumers: the package was produced with empty
dependency groups, so projects referencing MSTest.TestFramework built with the
analyzers silently disabled (acceptance tests AnalyzersShouldBeEnabled*,
MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*
all failed).
Root cause: the ProjectReference to MSTest.Analyzers.Package used
ReferenceOutputAssembly="false". NuGet pack omits the generated package
dependency for project references that do not reference the output assembly, so
the MSTest.Analyzers dependency was dropped entirely. Removing the attribute
makes pack emit `<dependency id="MSTest.Analyzers" include="...Analyzers,
BuildTransitive" />` at the co-built version while ExcludeAssets="compile;runtime"
still keeps the analyzer assembly out of this project's compile/runtime graph
(the analyzer package has IncludeBuildOutput=false, so there is no real assembly).
Verified by packing MSTest.TestFramework + MSTest.Analyzers locally and building a
consumer that references the package: it now reports `warning MSTEST0014` again.
net462 framework build remains clean (0 warnings) with the analyzers active.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 15:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 1

@Evangelink

This comment has been minimized.

Once MSTest.TestFramework correctly flows its MSTest.Analyzers dependency, the
analyzer projects' Microsoft.CodeAnalysis.* package references leaked
transitively through the framework's ProjectReference to in-repo consumers. That
forced Microsoft.CodeAnalysis.Common/CSharp 4.8.0 onto the source-generation test
projects (MSTest.SourceGeneration.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests),
which pin Roslyn 3.11.0, producing NU1608.
Roslyn is provided by the compiler host at analysis time and must never flow to
consumers, so mark Microsoft.CodeAnalysis.Analyzers/Common (MSTest.Analyzers) and
Microsoft.CodeAnalysis.CSharp.Workspaces (MSTest.Analyzers.CodeFixes) as
PrivateAssets="all". The produced MSTest.Analyzers package is unaffected
(SuppressDependenciesWhenPacking already yields zero dependencies and still ships
all analyzer assemblies).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

…ositive
The previous commit also marked Microsoft.CodeAnalysis.Analyzers PrivateAssets="all",
which changed the analyzer-authoring analyzer version that MSTest.Analyzers.CodeFixes
resolves and surfaced a known RS1024 false positive on
FlowTestContextCancellationTokenFixer.cs (the code already uses
SymbolEqualityComparer.Default). Only the Roslyn API package
(Microsoft.CodeAnalysis.Common) needs PrivateAssets to fix NU1608; revert the
attribute on Microsoft.CodeAnalysis.Analyzers so its pinned version keeps flowing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 17:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 1

…rift
MSTest.Analyzers.CodeFixes resolved Microsoft.CodeAnalysis.Analyzers transitively,
so a newer version (with a known RS1024 false positive on
new HashSet<ISymbol>(SymbolEqualityComparer.Default)) could win depending on the
restore graph. Add an explicit PrivateAssets="all" reference so it is always the
repo-pinned 5.3.0. Verified: CodeFixes restores 5.3.0 and builds clean (0 warnings).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

RunWithCooperativeCancellationAsync relied on new CancellationTokenSource(0)
having already cancelled its token at the IsCancellationRequested check, but the
0ms cancellation is scheduled on a timer rather than applied synchronously. On
fast machines (seen on net48 Release) the check ran before the timer fired, so
the action was invoked instead of failing immediately -- intermittently breaking
CancellationTimeoutHelperTests.RunWithCooperativeCancellationAsyncWhenTimeoutIsZeroReturnsFailureWithoutCallingAction.
Treat timeout == 0 as an immediate timeout explicitly. Production callers always
pass a positive configured timeout (Timeout.Infinite is -1, not 0), so behavior
is unchanged for them.
Verified: the full MSTestAdapter.PlatformServices.UnitTests net48 Release suite
(896 tests) passes, and the previously-failing test passes 6/6 runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 18:26

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 8/8 changed files
  • Comments generated: 1

@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9344

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 171 AIC · ⌖ 13.1 AIC · ⊞ 43.7K · [◷]( · )

@Evangelink
Amaury Levé (Evangelink) merged commit fd52133 into mainJun 22, 2026
33 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the evangelink/fix-main-mstest-package-downgrade branch June 22, 2026 20:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Evangelink@0101
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Fix main build broken by csproj-based MSTest packaging (#9259) - #9344

Merged
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade
Jun 22, 2026
Merged

Fix main build broken by csproj-based MSTest packaging (#9259)#9344
Amaury Levé (Evangelink) merged 7 commits into
mainfrom
evangelink/fix-main-mstest-package-downgrade

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented Jun 22, 2026

Copy link
Copy Markdown
Member

Problem

main is broken: the latest CI builds fail in the Build/Test tasks (Windows/Linux/macOS). The failures came in layers — fixing each revealed the next. This PR fixes all of them.

#StageSymptomRoot cause
1RestoreNU1605 downgrade of Microsoft.Testing.Platform.MSBuild#9259: adapter flows the locally-built platform MSBuild transitively, conflicting with the darc-pinned PackageReference
2CompileCS0234 missing MSTestAdapter.PlatformServices types#9259: adapter sets PrivateAssets="all" on PlatformServices, hiding it from in-repo consumers
3AfterSolutionBuildverify-nupkgs.ps1 file-count mismatch for MSTest.AotReflection.SourceGeneration#9338 made the PoC packable; not added to the expected-counts table
4Test (acceptance)AnalyzersShouldBeEnabled*, MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*#9259: MSTest.TestFramework was packed with empty dependency groups — the MSTest.Analyzers dependency was dropped, so analyzers no longer ran for consumers
5RestoreNU1608 Roslyn version conflict in the source-generation unit testsfixing #4 made the analyzer projects' Microsoft.CodeAnalysis.* refs leak transitively through the framework, clashing with the pinned Roslyn 3.11.0

The xlf drift that originally broke main was already fixed by #9339.

Fixes

  • test/Directory.Build.targets — under UseMSTestFromSource, reference Microsoft.Testing.Platform.MSBuild from source so both references resolve to the same version. (NU1605)
  • MSTest.IntegrationTests / MSTestAdapter.UnitTests — add a direct ProjectReference to MSTestAdapter.PlatformServices. (CS0234)
  • eng/verify-nupkgs.ps1 — add MSTest.AotReflection.SourceGeneration = 6. (verify-nupkgs)
  • TestFramework.Extensions.csproj — remove ReferenceOutputAssembly="false" from the MSTest.Analyzers.Package reference so pack emits <dependency id="MSTest.Analyzers" include="...Analyzers,BuildTransitive" /> at the co-built version. (analyzers)
  • MSTest.Analyzers / MSTest.Analyzers.CodeFixes — mark Microsoft.CodeAnalysis.* references PrivateAssets="all" so Roslyn (a compiler-host-provided dependency) never flows to consumers. (NU1608)

The adapter's intentional PrivateAssets settings are unchanged — the produced packages keep their historical dependency graphs.

Validation

  • Reproduced each failure on clean main (/p:OfficialBuildId=20260622.12, so the build version exceeds the darc pin) and confirmed each fix resolves it.
  • Built all affected projects (integration/adapter/source-gen/analyzer unit tests) — restore + build with 0 errors; the two source-gen test projects restore without NU1608.
  • Analyzers: packed MSTest.TestFramework + MSTest.Analyzers, built a consumer referencing the package → warning MSTEST0014 fires again. The MSTest.Analyzers package still ships all analyzer assemblies with zero dependencies; the framework net462 build stays clean with analyzers active.

Refs #9259, #9338.

PR #9259 (csproj packing, removing nuspec) introduced two regressions on
MSTest.TestAdapter's project references that broke the in-repo build once the
daily build number rolled past the dogfood pin:
1. NU1605 (restore): the adapter now ProjectReferences
Microsoft.Testing.Platform.MSBuild with PrivateAssets="none", flowing the
locally built platform-MSBuild (current build version) transitively to
in-repo consumers. Test projects with UseMSTestFromSource also PackageReference
the darc-pinned version, producing a package downgrade. Reference the platform
MSBuild from source when UseMSTestFromSource is set so both paths use the same
(project) version.
2. CS0234 (compile): the adapter now suppresses MSTestAdapter.PlatformServices as
a flowed dependency (PrivateAssets="all", correct for the produced package),
so in-repo consumers no longer see its (internals-visible) types. Reference
PlatformServices directly from MSTest.IntegrationTests and MSTestAdapter.UnitTests.
Validated by building the affected projects with /p:OfficialBuildId=20260622.12
(reproducing the CI build version > pin) -- restore and compile now succeed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 14:00

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the main branch build break caused by the csproj-based MSTest.TestAdapter packaging changes (#9259) by aligning in-repo test project references with the new PrivateAssets behavior and avoiding a restore-time NU1605 downgrade scenario when UseMSTestFromSource=true.

Changes:

  • Add direct ProjectReference to MSTestAdapter.PlatformServices for test projects that compile against its types, since it no longer flows transitively from MSTest.TestAdapter due to PrivateAssets="all".
  • Replace a Microsoft.Testing.Platform.MSBuildPackageReference with a source ProjectReference when UseMSTestFromSource=true to eliminate restore downgrades against the locally-built MSBuild integration.
  • Document the rationale inline in the affected project files / targets.
Show a summary per file
FileDescription
test/UnitTests/MSTestAdapter.UnitTests/MSTestAdapter.UnitTests.csprojAdds direct reference to MSTestAdapter.PlatformServices so unit tests can compile against its APIs despite PrivateAssets="all" on the adapter’s reference.
test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csprojAdds direct reference to MSTestAdapter.PlatformServices to restore compile-time access for integration test code using those types.
test/Directory.Build.targetsSwitches Microsoft.Testing.Platform.MSBuild from PackageReference to ProjectReference under UseMSTestFromSource=true to prevent NU1605 downgrade vs the transitively-referenced source-built project.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@Evangelink

This comment has been minimized.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.

Review notes (all dimensions)

Scope: 3 MSBuild project files changed (test/Directory.Build.targets, MSTest.IntegrationTests.csproj, MSTestAdapter.UnitTests.csproj). No C# runtime code touched.

DimensionResultNotes
1. Algorithmic Correctness✅ LGTMFix correctly targets the root cause: PrivateAssets="all" on the MSTestAdapter.PlatformServicesProjectReference in MSTest.TestAdapter prevents the assembly from flowing as a compile-time reference to consumers. Adding direct ProjectReference entries in both consuming test projects restores the reference. The PackageReference→ProjectReference change in Directory.Build.targets correctly resolves the NU1605 downgrade by ensuring both the direct reference and the transitively-flowed one resolve to the same locally-built project version.
2. Threading & ConcurrencyN/ANo C# code changed.
3. Security & IPC Contract SafetyN/ABuild config changes only.
4. Public API & Binary CompatibilityN/ANo public API touched.
5. Performance & AllocationsN/ANo runtime code changed.
6. Cross-TFM Compatibility✅ LGTMMSTestAdapter.PlatformServices is built for all TFMs that MSTestAdapter.UnitTests targets (net462;net48;net8.0;net9.0;WinUiMinimum), because MSTest.TestAdapter already includes them all. The single-TFM MSTest.IntegrationTests ($(NetFrameworkMinimum)) is also covered.
7. Resource & IDisposable ManagementN/ANo code changed.
8. Defensive Coding at BoundariesN/ANo code changed.
9. Localization & ResourcesN/ANo strings changed.
10. Test IsolationN/ANo test code changed.
11. Assertion QualityN/ANo test code changed.
12. Flakiness PatternsN/ANo test code changed.
13. Test Completeness & Coverage✅ LGTMThis is a build/restore fix with no new code paths; the author validated by reproducing the failure with /p:OfficialBuildId=20260622.12 and confirming all 6 affected projects restore and build clean. No additional tests needed.
14. Data-Driven Test CoverageN/ANo test code changed.
15. Code Structure & SimplificationN/ANo C# code changed.
16. Naming & ConventionsN/ANo C# code changed.
17. Documentation Accuracy✅ LGTMAll three added XML comments accurately explain why the reference is needed (link to #9259, explain the PrivateAssets="all" mechanism). Comments describe the intent, not just what the element does.
18. Analyzer & Code Fix QualityN/ANo src/Analyzers/ files changed.
19. IPC Wire CompatibilityN/ANo serialization code changed.
20. Build Infrastructure & Dependencies✅ LGTMThe PackageReference→ProjectReference swap is gated on UseMSTestFromSource='true' (matching the old condition), sits inside the existing EnableMSTestRunner OR UseInternalTestFramework outer ItemGroup, and references a first-party in-repo project that is always resolvable. The direct ProjectReference entries in the two test projects do not duplicate the assembly in output since MSBuild deduplicates project builds. InternalsVisibleTo coverage confirmed: MSTestAdapter.PlatformServices.csproj already declares InternalsVisibleTo for both Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests and MSTest.IntegrationTests. The four other UseMSTestFromSource=true projects omitted from the fix (MSTest.VstestConsoleWrapper.IntegrationTests, MSTest.Analyzers.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests, MSTest.SelfRealExamples.UnitTests) do not consume MSTestAdapter.PlatformServices internals directly and are not listed in its InternalsVisibleTo; they build fine without an explicit reference.
21. Scope & PR Discipline✅ LGTMSingle, tightly-scoped concern. Clear description with root-cause analysis, precise reproduction steps, and explicit validation. Refs #9259 appropriately.
22. PowerShell Scripting HygieneN/ANo .ps1 files changed.
MSBuild Authoring (supplemental)✅ LGTMCondition quoting is consistent with the repo style ('$(Prop)' == 'value'). The new ProjectReference has no PrivateAssets (defaults to all-assets-flow), which is the correct behavior for a test project reference. No DependsOn append issues, no stray whitespace, no condition ordering problems.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 22, 2026
…ounts
After the build progresses past the restore/compile fixes, verify-nupkgs.ps1
fails because MSTest.AotReflection.SourceGeneration (made packable as a
non-shipping PoC in #9338) is a 4.3.0 package not present in the expected
file-count table, so it is validated with an empty expected value. Add it with
its actual content count (6: [Content_Types].xml, Icon.png, .nuspec, the
analyzer dll, .psmdcp, .rels).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ency (#9259)
After the move to csproj-based packing (#9259), MSTest.TestFramework no longer
flowed the MSTest analyzers to consumers: the package was produced with empty
dependency groups, so projects referencing MSTest.TestFramework built with the
analyzers silently disabled (acceptance tests AnalyzersShouldBeEnabled*,
MSTEST0001/0014, AnalyzerMessagesShouldBeLocalized, VerifyMSTestAnalysisMode*
all failed).
Root cause: the ProjectReference to MSTest.Analyzers.Package used
ReferenceOutputAssembly="false". NuGet pack omits the generated package
dependency for project references that do not reference the output assembly, so
the MSTest.Analyzers dependency was dropped entirely. Removing the attribute
makes pack emit `<dependency id="MSTest.Analyzers" include="...Analyzers,
BuildTransitive" />` at the co-built version while ExcludeAssets="compile;runtime"
still keeps the analyzer assembly out of this project's compile/runtime graph
(the analyzer package has IncludeBuildOutput=false, so there is no real assembly).
Verified by packing MSTest.TestFramework + MSTest.Analyzers locally and building a
consumer that references the package: it now reports `warning MSTEST0014` again.
net462 framework build remains clean (0 warnings) with the analyzers active.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 15:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 1

@Evangelink

This comment has been minimized.

Once MSTest.TestFramework correctly flows its MSTest.Analyzers dependency, the
analyzer projects' Microsoft.CodeAnalysis.* package references leaked
transitively through the framework's ProjectReference to in-repo consumers. That
forced Microsoft.CodeAnalysis.Common/CSharp 4.8.0 onto the source-generation test
projects (MSTest.SourceGeneration.UnitTests, MSTest.AotReflection.SourceGeneration.UnitTests),
which pin Roslyn 3.11.0, producing NU1608.
Roslyn is provided by the compiler host at analysis time and must never flow to
consumers, so mark Microsoft.CodeAnalysis.Analyzers/Common (MSTest.Analyzers) and
Microsoft.CodeAnalysis.CSharp.Workspaces (MSTest.Analyzers.CodeFixes) as
PrivateAssets="all". The produced MSTest.Analyzers package is unaffected
(SuppressDependenciesWhenPacking already yields zero dependencies and still ships
all analyzer assemblies).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

…ositive
The previous commit also marked Microsoft.CodeAnalysis.Analyzers PrivateAssets="all",
which changed the analyzer-authoring analyzer version that MSTest.Analyzers.CodeFixes
resolves and surfaced a known RS1024 false positive on
FlowTestContextCancellationTokenFixer.cs (the code already uses
SymbolEqualityComparer.Default). Only the Roslyn API package
(Microsoft.CodeAnalysis.Common) needs PrivateAssets to fix NU1608; revert the
attribute on Microsoft.CodeAnalysis.Analyzers so its pinned version keeps flowing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 17:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 1

…rift
MSTest.Analyzers.CodeFixes resolved Microsoft.CodeAnalysis.Analyzers transitively,
so a newer version (with a known RS1024 false positive on
new HashSet<ISymbol>(SymbolEqualityComparer.Default)) could win depending on the
restore graph. Add an explicit PrivateAssets="all" reference so it is always the
repo-pinned 5.3.0. Verified: CodeFixes restores 5.3.0 and builds clean (0 warnings).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

This comment has been minimized.

RunWithCooperativeCancellationAsync relied on new CancellationTokenSource(0)
having already cancelled its token at the IsCancellationRequested check, but the
0ms cancellation is scheduled on a timer rather than applied synchronously. On
fast machines (seen on net48 Release) the check ran before the timer fired, so
the action was invoked instead of failing immediately -- intermittently breaking
CancellationTimeoutHelperTests.RunWithCooperativeCancellationAsyncWhenTimeoutIsZeroReturnsFailureWithoutCallingAction.
Treat timeout == 0 as an immediate timeout explicitly. Production callers always
pass a positive configured timeout (Timeout.Infinite is -1, not 0), so behavior
is unchanged for them.
Verified: the full MSTestAdapter.PlatformServices.UnitTests net48 Release suite
(896 tests) passes, and the previously-failing test passes 6/6 runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 22, 2026 18:26

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 8/8 changed files
  • Comments generated: 1

@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9344

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 171 AIC · ⌖ 13.1 AIC · ⊞ 43.7K · [◷]( · )

@Evangelink
Amaury Levé (Evangelink) merged commit fd52133 into mainJun 22, 2026
33 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the evangelink/fix-main-mstest-package-downgrade branch June 22, 2026 20:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Evangelink@0101