[fix] Set IsPackable=false in Microsoft.NET.Test.Sdk.props#15793
[fix] Set IsPackable=false in Microsoft.NET.Test.Sdk.props#15793nohwnd wants to merge 2 commits into
Conversation
Test projects using Microsoft.NET.Test.Sdk should not produce NuGet packages by default. Previously a target handled this, but it was removed. .NET 10 SDK sets IsPackable=false when IsTestProject=true, but .NET 9 does not, leaving test projects packable by default. Fixes #15309 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses a regression in SDK behavior where test projects can become packable by default when using Microsoft.NET.Test.Sdk 18.x with .NET 9 (because the SDK no longer implicitly sets IsPackable=false for IsTestProject=true in that combination). The change ensures test projects default to non-packable again, while still allowing explicit opt-in by users.
Changes:
- Set
IsPackable=falseinMicrosoft.NET.Test.Sdk.propswhenIsPackableis not already specified.
nohwnd
left a comment
There was a problem hiding this comment.
The fix is correct and minimal. The condition '$(IsPackable)' == '' is the right guard — it fires only when IsPackable hasn't been set, so user overrides (IsPackable=true in the project file) still work, and .NET 10 SDK's own setting of IsPackable=false is correctly preserved without double-evaluation.
🧠 Reviewed by Expert Code Reviewer
🧠 Reviewed by Expert Code Reviewer 🧠
Youssef1313
left a comment
There was a problem hiding this comment.
As is, this doesn't address the concern I pointed out in the linked issue.
The packaging of Microsoft.NET.Test.Sdk is wrong and is a regression. It adds TFM-specific folders in buildMultiTargeting.
buildMultiTargeting is (by definition) imported for multi-targeting for the outer build when no specific TargetFramework value is known.
I have doubts that the props/targets shipped in buildMultiTargeting are ever imported today.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
nohwnd
left a comment
There was a problem hiding this comment.
The fix is correct. The condition '$(IsPackable)' == '' is idiomatic MSBuild — it only sets IsPackable=false when the property hasn't already been defined, so explicit IsPackable=true in a project file continues to work. No package content is added or removed, so expected-nupkg-file-counts.json does not need updating. The PR description accurately describes the root cause and the fix.
🧠 Reviewed by Expert Code Reviewer 🧠
🧠 Reviewed by Expert Code Reviewer 🧠
|
All CI checks are now fully green ✅ (Windows Release, Ubuntu, macOS all passed — build 1423658, 2026-05-17). No unaddressed review comments. This PR is ready to merge but is still in draft state. Please click "Ready for review" to undraft it.
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "dev.azure.com"See Network Configuration for more information.
|
🤖 This is an automated fix generated by the Issue Repro Triage agent.
Fixes #15309
Root Cause
Microsoft.NET.Test.Sdk.propssetsIsTestProject=truebut does not setIsPackable=false. In an older version of the SDK (17.13), a dedicated target handled settingIsPackable=falsewhenIsTestProject=true. That target was removed in version 18.0.The .NET 10 SDK itself sets
IsPackable=falsewhenIsTestProject=true(explaining why the issue doesn't reproduce with the .NET 10 SDK), but .NET 9 does not — leaving test projects packable by default whenMicrosoft.NET.Test.Sdk18.x is used.Fix
Added
<IsPackable Condition="'$(IsPackable)' == ''">false</IsPackable>toMicrosoft.NET.Test.Sdk.props. The condition ensures that users who explicitly setIsPackable=truein their project file can still override this default.Verification
Build succeeded with 0 warnings and 0 errors.