[rel/4.3] Avoid MSB4011 duplicate-import warnings when layering MSTest.Sdk on another base SDK#9584
Merged
Merged
Conversation
…nother base SDK (#9562) Guard the Microsoft.NET.Sdk import in MSTest.Sdk's Sdk.props/Sdk.targets behind a new _MSTestSdkImportsMicrosoftNETSdk property. MSTest.Sdk now only imports the base .NET SDK when no other SDK has already done so (detected via UsingMicrosoftNETSdk, which Microsoft.NET.Sdk sets very early). This lets MSTest.Sdk be layered on top of a different base SDK such as Microsoft.NET.Sdk.Web via manual SDK imports without emitting MSB4011 warnings. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
0101
approved these changes
Jul 3, 2026
0101
approved these changes
Jul 3, 2026
0101
approved these changes
Jul 3, 2026
0101
approved these changes
Jul 3, 2026
0101
approved these changes
Jul 3, 2026
0101
approved these changes
Jul 3, 2026
0101
approved these changes
Jul 3, 2026
…l SDK imports The versioned SDK form (MSTest.Sdk/version) only resolves on the outer <Project Sdk> attribute, not on <Import Sdk=...>, which caused MSB4236 'SDK could not be found' in CI. Pin the version through global.json's msbuild-sdks instead, matching the canonical way to pin MSBuild project SDK versions for manual/mixed imports. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
0101
approved these changes
Jul 3, 2026
Contributor
🧪 Test quality grade — PR #9584
This advisory comment was generated automatically. Grades are heuristic and informational — they do not block merging. Re-run with
|
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.
Backport of #9565 onto
rel/4.3.Fixes #9562 for the 4.3 release branch.
Problem
When
MSTest.Sdkis layered on top of a different base SDK (for exampleMicrosoft.NET.Sdk.Web) using manual SDK imports, both SDKs importMicrosoft.NET.Sdk, producing MSB4011 duplicate-import warnings.Fix
Guard the
Microsoft.NET.Sdkimport inMSTest.Sdk'sSdk.props/Sdk.targetsbehind a new_MSTestSdkImportsMicrosoftNETSdkproperty.MSTest.Sdknow only imports the base .NET SDK when no other SDK has already done so (detected viaUsingMicrosoftNETSdk, whichMicrosoft.NET.Sdksets very early), and remembers that decision soSdk.targetsimports the base targets only when it also imported the base props.Changes
src/Package/MSTest.Sdk/Sdk/Sdk.props.template— introduce and set_MSTestSdkImportsMicrosoftNETSdk; guard the top import.src/Package/MSTest.Sdk/Sdk/Sdk.targets— guard the bottom import with the same property.src/Package/MSTest.Sdk/README.md— document manual layering on top of another base SDK.test/IntegrationTests/MSTest.Acceptance.IntegrationTests/SdkTests.cs— new acceptance testMSTestSdk_LayeredOnTopOfWebSdk_BuildsWithoutDuplicateImportWarningsverifying a manually-layeredMicrosoft.NET.Sdk.Web+MSTest.Sdkproject builds and runs without MSB4011.Cherry-picked from
7db4e75(retains the originalCo-authored-bytrailer).