MSTest.Sdk: stop using VersionOverride so CPM with CentralPackageVersionOverrideEnabled=false works#7766
Merged
Evangelink merged 4 commits intomainfrom Apr 21, 2026
Conversation
…ersion injection Agent-Logs-Url: https://github.com/microsoft/testfx/sessions/ef073c73-3140-4f65-b890-f3911b7f92b7 Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/testfx/sessions/ef073c73-3140-4f65-b890-f3911b7f92b7 Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CentralPackageVersionOverrideEnabled with MSTest/Sdk
MSTest.Sdk: stop using VersionOverride so CPM with CentralPackageVersionOverrideEnabled=false works
Apr 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates MSTest.Sdk MSBuild targets to stop relying on VersionOverride so Central Package Management (CPM) restores succeed even when CentralPackageVersionOverrideEnabled=false.
Changes:
- Replace
VersionOverride-based implicitPackageReferenceversioning with a CPM-aware pattern:Versionmetadata when CPM is off,PackageVersionitems when CPM is on. - Fix/strengthen the CPM acceptance test to actually enable CPM and set
CentralPackageVersionOverrideEnabled=false. - Refresh MSTest.Sdk README design notes to document the new approach and correct an attribute name typo.
Show a summary per file
| File | Description |
|---|---|
| test/IntegrationTests/MSTest.Acceptance.IntegrationTests/SdkTests.cs | Updates acceptance test to enable CPM + strict override mode and validate restore/build still succeeds. |
| src/Package/MSTest.Sdk/Sdk/VSTest/VSTest.targets | Switches implicit package versioning to CPM-aware Version/PackageVersion pattern. |
| src/Package/MSTest.Sdk/Sdk/Runner/NativeAOT.targets | Applies the CPM-aware versioning pattern to NativeAOT runner dependencies and extensions. |
| src/Package/MSTest.Sdk/Sdk/Runner/ClassicEngine.targets | Applies the CPM-aware versioning pattern to Classic runner dependencies and extensions. |
| src/Package/MSTest.Sdk/Sdk/Features/Playwright.targets | Applies the CPM-aware versioning pattern for the Playwright feature package. |
| src/Package/MSTest.Sdk/Sdk/Features/Aspire.targets | Applies the CPM-aware versioning pattern for the Aspire feature package. |
| src/Package/MSTest.Sdk/README.md | Documents the new guidance/pattern and removes VersionOverride recommendation. |
Copilot's findings
- Files reviewed: 7/7 changed files
- Comments generated: 2
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
nohwnd
approved these changes
Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MSTest.Sdk's
.targetsset bothVersionandVersionOverrideon every implicitPackageReference. Projects that enable Central Package Management with<CentralPackageVersionOverrideEnabled>false</CentralPackageVersionOverrideEnabled>then fail restore with NU1013 (see discussion #7440, issue #7441).Changes
ManagePackageVersionsCentrallyin every SDK.targets(VSTest,Runner/ClassicEngine,Runner/NativeAOT,Features/Aspire,Features/Playwright):Versionas conditional nested metadata on thePackageReference.PackageReferencewith no version metadata and add a matchingPackageVersionitem — works regardless ofCentralPackageVersionOverrideEnabled.RunTests_With_CentralPackageManagement_Standalonepreviously didn't actually enable CPM. It now generates aDirectory.Packages.propswithManagePackageVersionsCentrally=trueandCentralPackageVersionOverrideEnabled=false, exercising the regressing scenario.VersionOverrideis no longer used; also fixed anIsImplictlyDefined→IsImplicitlyDefinedtypo.Pattern applied
Compatibility note
Users who currently declare a
PackageVersionfor SDK-managed packages (e.g.MSTest.TestFramework,Microsoft.NET.Test.Sdk) in their ownDirectory.Packages.propswill now get a duplicate-PackageVersionerror and should remove those entries — overriding the SDK's defaults is done via the existingMSTestVersion/MicrosoftNETTestSdkVersion/etc. properties.