Skip to content

[fix] Set IsPackable=false in Microsoft.NET.Test.Sdk.props#15793

Draft
nohwnd wants to merge 2 commits into
mainfrom
fix/issue-15309-df1effb41d0d33da
Draft

[fix] Set IsPackable=false in Microsoft.NET.Test.Sdk.props#15793
nohwnd wants to merge 2 commits into
mainfrom
fix/issue-15309-df1effb41d0d33da

Conversation

@nohwnd
Copy link
Copy Markdown
Member

@nohwnd nohwnd commented May 16, 2026

🤖 This is an automated fix generated by the Issue Repro Triage agent.

Fixes #15309

Root Cause

Microsoft.NET.Test.Sdk.props sets IsTestProject=true but does not set IsPackable=false. In an older version of the SDK (17.13), a dedicated target handled setting IsPackable=false when IsTestProject=true. That target was removed in version 18.0.

The .NET 10 SDK itself sets IsPackable=false when IsTestProject=true (explaining why the issue doesn't reproduce with the .NET 10 SDK), but .NET 9 does not — leaving test projects packable by default when Microsoft.NET.Test.Sdk 18.x is used.

Fix

Added <IsPackable Condition="'$(IsPackable)' == ''">false</IsPackable> to Microsoft.NET.Test.Sdk.props. The condition ensures that users who explicitly set IsPackable=true in their project file can still override this default.

Verification

Build succeeded with 0 warnings and 0 errors.

🔍 Triaged by Issue Repro Triage & Auto-Fix 🔍

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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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=false in Microsoft.NET.Test.Sdk.props when IsPackable is not already specified.

Copy link
Copy Markdown
Member Author

@nohwnd nohwnd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🧠

Copy link
Copy Markdown
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented May 17, 2026

Commit pushed: 0545ada

🔧 Iterated by PR Iteration Agent 🔧

@nohwnd

This comment has been minimized.

Copy link
Copy Markdown
Member Author

@nohwnd nohwnd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🧠

@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented May 19, 2026

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.

🔧 Iterated by PR Iteration Agent 🔧

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • dev.azure.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "dev.azure.com"

See Network Configuration for more information.

🔧 Iterated by PR Iteration Agent 🔧

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.

MSTest.Sdk/4.0.1 is packable by default and creates a NuGet package.

3 participants