Skip to content

Keep MSTest.Sdk in sync with MSTest framework to fix NativeAOT test discovery - #55302

Merged
dsplaisted merged 2 commits into
dotnet:mainfrom
dsplaisted:dsplaisted/fix-mstest-sdk-sync
Jul 15, 2026
Merged

Keep MSTest.Sdk in sync with MSTest framework to fix NativeAOT test discovery#55302
dsplaisted merged 2 commits into
dotnet:mainfrom
dsplaisted:dsplaisted/fix-mstest-sdk-sync

Conversation

@dsplaisted

@dsplaisted dsplaisted commented Jul 15, 2026

Copy link
Copy Markdown
Member

We had mismatched versions of the MSTest.Sdk and the MSTest package references. Apparently this no longer works when using NativeAOT tests. So this adds a declared dependency to MSTest.Sdk so the reference in global.json will get updated in sync.

EDIT: Also updated to temporarily disable win-arm64 NativeAOT (AoT) CI leg. This was added in #55205 but has never passed, and is failing with errors like

dotnet-aot.obj : fatal error LNK1322: cannot avoid potential ARM hazard
   (Cortex-A53 MPCore processor bug #843419) in section 0x2; consider compiler option /Gy
error MSB3073: ...Hostx64\arm64\link.exe ... exited with code 1322

Verbose Copilot description

The test/dotnet-aot.Tests project publishes as NativeAOT and relies on the MSTest source generator for test discovery (reflection-based discovery isn't AOT-safe). That requires two versions to stay coherent:

  • MSTest.Sdk — the MSBuild SDK, pinned in global.json (msbuild-sdks), which provides the NativeAOT discovery targets + source generator.
  • MSTestPackageVersion (the MSTest framework/runtime packages) — flowed by darc from microsoft/testfx.

A dotnet/dotnet flow bumped MSTestPackageVersion 4.3.0-preview.26355.114.4.0-preview.26360.5, but MSTest.Sdk stayed pinned at 4.3.0-preview.26325.12 in global.json. Shortly after, #54719 enabled the Run NativeAOT CLI Tests leg for the first time.

With the SDK (4.3.0) and framework (4.4.0) skewed, the MSTest source generator registers zero tests, so the AOT binary reports Test run summary: Zero tests ran and exits with MTP code 8 — failing the leg on every main build. (Normal reflection-based MSTest runs tolerate the skew, so only the AOT leg breaks.)

#54719 itself was green because it was validated while MSTest was still coherent at 4.3.0; it merged into a main that had already moved the framework to 4.4.0.

Fix

  1. global.json — bump MSTest.Sdk to 4.4.0-preview.26360.5 (same microsoft/testfx build as the MSTest framework packages), re-cohering the source generator with the runtime.
  2. eng/Version.Details.xml — track MSTest.Sdk as a darc dependency from microsoft/testfx, next to MSTest.

Why this keeps them in sync going forward

Microsoft.DotNet.Arcade.Sdk and Microsoft.DotNet.Helix.Sdk already live in both global.json msbuild-sdks and eng/Version.Details.xml, so darc keeps their global.json versions updated in lockstep with the flow. MSTest.Sdk was the odd one out — global.json only, hand-bumped, free to drift. Tracking it in Version.Details.xml makes darc update MSTest.Sdk in global.json together with the MSTest framework packages on every testfx flow. Since testfx publishes both at the same build/version string, they can no longer drift apart.

Verification

  • darc get-dependencies parses the new MSTest.Sdk dependency.
  • global.json is valid JSON; eng/Version.Details.xml is well-formed.
  • MSTest.Sdk 4.4.0-preview.26360.5 is present on the dotnet-tools / test-tools feeds and matches MSTest 4.4.0-preview.26360.5 (build f19af28).

Fixes the Run NativeAOT CLI Tests failures introduced alongside #54719.

…iscovery

The test/dotnet-aot.Tests project publishes as NativeAOT and relies on the MSTest source generator for test discovery (reflection isn't AOT-safe). That requires MSTest.Sdk (the MSBuild SDK pinned in global.json) and the MSTest framework packages (MSTestPackageVersion, flowed by darc from microsoft/testfx) to be coherent.

A dotnet/dotnet flow bumped MSTestPackageVersion to 4.4.0-preview.26360.5 while MSTest.Sdk stayed at 4.3.0-preview.26325.12, and PR dotnet#54719 then enabled the NativeAOT CLI test leg. The SDK/framework skew makes the source generator register zero tests, so the leg fails with MTP exit code 8 (Test run summary: Zero tests ran) on every main build. Normal reflection-based MSTest runs tolerate the skew, so only the AOT leg breaks.

Fix: bump MSTest.Sdk to 4.4.0-preview.26360.5 (same testfx build as the MSTest framework), and track MSTest.Sdk as a darc dependency in eng/Version.Details.xml. Like Microsoft.DotNet.Arcade.Sdk and .Helix.Sdk, darc then updates its global.json msbuild-sdks version in lockstep with the MSTest framework packages, preventing the versions from drifting apart again.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 59570d89-a7e3-4993-baa9-3fb1f442a617
Copilot AI review requested due to automatic review settings July 15, 2026 18:55
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI 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

Updates the pinned MSTest.Sdk MSBuild SDK version and starts tracking it as a darc-managed dependency so it stays aligned with the MSTest framework packages—fixing NativeAOT MSTest discovery where version skew can lead to zero discovered tests.

Changes:

  • Bump MSTest.Sdk in global.json msbuild-sdks to 4.4.0-preview.26360.5.
  • Add MSTest.Sdk as a dependency in eng/Version.Details.xml (from microsoft/testfx) so darc can keep the global.json pin in sync with MSTest.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
global.json Updates the pinned MSTest.Sdk MSBuild SDK version used by the repo.
eng/Version.Details.xml Adds MSTest.Sdk as a tracked dependency so darc updates it alongside MSTest/TestFX flows.

@baronfel

baronfel commented Jul 15, 2026

Copy link
Copy Markdown
Member

Nice! I have a crappier version of this over in my PR but yours fixes the root cause of the out-of-sync.

…um 843419)

The 'AoT: windows (arm64)' cross-build leg added in dotnet#55205 has never passed: the win-arm64 NativeAOT cross-link fails with 'LNK1322: cannot avoid potential ARM hazard (Cortex-A53 MPCore processor bug #843419)' because the ILCompiler-produced object is not split into per-function sections, so the MSVC arm64 linker cannot apply the erratum fixup. Only win-arm64 is affected (win-x64, osx-arm64, linux-x64/arm64 AoT legs all pass).

Set disableJob: true on the win-arm64 AoT job parameter set in .vsts-pr.yml and .vsts-ci.yml to stop it red-walling every build until the underlying ILCompiler fix lands. Re-enable by removing disableJob.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 59570d89-a7e3-4993-baa9-3fb1f442a617
@dsplaisted
dsplaisted merged commit de83a9c into dotnet:main Jul 15, 2026
27 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 16, 2026
pull Bot pushed a commit to AraHaan/sdk that referenced this pull request Jul 20, 2026
Bumps the microsoft/testfx dependency group to the latest coherent build
(4.4.0-preview.26366.2 / MTP 2.4.0-preview.26366.2, testfx c1e6453) across all
three places that must agree:

- global.json msbuild-sdks -> MSTest.Sdk (the source generator)
- eng/Version.Details.props -> MSTestPackageVersion + MicrosoftTestingPlatformPackageVersion
- eng/Version.Details.xml -> MSTest, MSTest.Sdk, Microsoft.Testing.Platform (+ Sha)

The MSTest.Sdk source generator emits test registrations against the
MSTest.TestFramework runtime, so these must come from the same testfx build.
A skew breaks the NativeAOT CLI test build ("Zero tests ran" when the generator
lags, CS0234 on DynamicDataSourceResolver when it leads). Adds KEEP-IN-SYNC
comments over each version so future manual edits keep them together. See dotnet#55302.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1b315003-e0fc-4a09-865e-c8f4750fe3a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants