Skip to content

[rel/4.3] Avoid MSB4011 duplicate-import warnings when layering MSTest.Sdk on another base SDK#9584

Merged
Evangelink merged 2 commits into
rel/4.3from
dev/amauryleve/musical-potato
Jul 3, 2026
Merged

[rel/4.3] Avoid MSB4011 duplicate-import warnings when layering MSTest.Sdk on another base SDK#9584
Evangelink merged 2 commits into
rel/4.3from
dev/amauryleve/musical-potato

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Backport of #9565 onto rel/4.3.

Fixes #9562 for the 4.3 release branch.

Problem

When MSTest.Sdk is layered on top of a different base SDK (for example Microsoft.NET.Sdk.Web) using manual SDK imports, both SDKs import Microsoft.NET.Sdk, producing MSB4011 duplicate-import warnings.

Fix

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), and remembers that decision so Sdk.targets imports 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 test MSTestSdk_LayeredOnTopOfWebSdk_BuildsWithoutDuplicateImportWarnings verifying a manually-layered Microsoft.NET.Sdk.Web + MSTest.Sdk project builds and runs without MSB4011.

Cherry-picked from 7db4e75 (retains the original Co-authored-by trailer).

…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>
@Evangelink Evangelink added the state/needs-review Awaiting review from the team. label Jul 3, 2026
@Evangelink Evangelink changed the title Avoid MSB4011 duplicate-import warnings when layering MSTest.Sdk on another base SDK [rel/4.3] Avoid MSB4011 duplicate-import warnings when layering MSTest.Sdk on another base SDK Jul 3, 2026
@Evangelink Evangelink enabled auto-merge (squash) July 3, 2026 14:47
…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>
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🧪 Test quality grade — PR #9584

GradeTestNotes
A (90–100) new SdkTests.
MSTestSdk_
LayeredOnTopOfWebSdk_
BuildsWithoutDuplicateImportWarnings
Clean AAA integration test; build-success, no-MSB4011, and host-run assertions all directly verify the layered-SDK feature. No issues found.

This advisory comment was generated automatically. Grades are heuristic and informational — they do not block merging. 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. · 37.3 AIC · ⌖ 7.58 AIC · ⊞ 9.5K · [◷]( · )

@Evangelink Evangelink merged commit 6f31d81 into rel/4.3 Jul 3, 2026
37 checks passed
@Evangelink Evangelink deleted the dev/amauryleve/musical-potato branch July 3, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants