Skip to content

Pack MSTest packages from csproj (remove .nuspec)#9259

Open
Evangelink wants to merge 4 commits into
microsoft:mainfrom
Evangelink:evangelink/pack-from-csproj-no-nuspec
Open

Pack MSTest packages from csproj (remove .nuspec)#9259
Evangelink wants to merge 4 commits into
microsoft:mainfrom
Evangelink:evangelink/pack-from-csproj-no-nuspec

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary

Replaces the hand-authored .nuspec files for MSTest.Sdk, MSTest.TestFramework and MSTest.TestAdapter with SDK-style packaging driven entirely from the .csproj, and deletes the now-unused .nuspec files (including the NonWindows variants).

How

  • IncludeBuildOutput=false + TargetsForTfmSpecificContentInPackage / TfmSpecificPackageFile reproduce the custom per-TFM layout (lib vs buildTransitive, WinUI/UWP variants, localized satellites).
  • Static build/ and buildTransitive/ assets via None Pack=true PackagePath (net462/uap gated to Windows builds).
  • Curated dependencies via ProjectReference: PrivateAssets="none" where assets (analyzers, build targets) must flow to consumers, PrivateAssets="all" for bundled-but-not-dependency assemblies.
  • The core TestFramework project (PackageId=NotPublishable) is bundled into lib and must keep flowing transitively for downstream compilation, so it can't use PrivateAssets="all". NuGet then emits an invalid NotPublishable dependency that PackTask reads from the assets file; a post-pack target strips that single dependency from the produced MSTest.TestFramework package using built-in Unzip/ZipDirectory tasks.

Metadata previously provided by the nuspec (icon, PACKAGE.md readme, license, repository info) is now provided automatically by Arcade / Directory.Build.targets.

Verification

Each package was packed (note: desktop MSBuild.exe is required because of the uap10.0 TFM) and compared against:

  • the previous nuspec-built artifacts from the same source, and
  • the published 4.2.3 packages on NuGet.org.

lib/build/buildTransitive file layouts are identical; dependencies are preserved. The only deltas vs 4.2.3 are legitimate post-4.2.3 source changes (System.Memory from #9209, Parallelize.targets from class-level [Retry]) and functionally-equivalent SDK-pack formatting (extra net8.0-windows/net9.0-windows dependency groups carrying the same deps, UAP10.0.16299 moniker, include="All" attributes).

Note: packing these packages requires desktop MSBuild.exe (the uap10.0 TFM via MSBuild.Sdk.Extras cannot pack under dotnet), which matches the existing official build.

…roj (remove .nuspec)

Replace the hand-authored .nuspec files for MSTest.Sdk, MSTest.TestFramework and
MSTest.TestAdapter with SDK-style packaging driven entirely from the .csproj using
MSBuild elements, and delete the now-unused .nuspec files (including the NonWindows
variants).

Key techniques:
- IncludeBuildOutput=false + TargetsForTfmSpecificContentInPackage / TfmSpecificPackageFile
  to reproduce the custom per-TFM layout (lib vs buildTransitive, WinUI/UWP variants,
  localized satellites) exactly.
- Static build/ and buildTransitive/ assets via None Pack=true PackagePath (net462/uap
  gated to Windows builds).
- Curated dependencies via ProjectReference: PrivateAssets="none" where assets (analyzers,
  build targets) must flow to consumers, PrivateAssets="all" for bundled-but-not-dependency
  assemblies.
- The core TestFramework project (PackageId=NotPublishable) is bundled into lib and must keep
  flowing transitively for downstream compilation, so it cannot use PrivateAssets="all"; a
  post-pack target strips the resulting invalid NotPublishable dependency from the produced
  MSTest.TestFramework package using built-in Unzip/ZipDirectory tasks.

Verified the produced packages have identical lib/build/buildTransitive layouts and equivalent
dependencies versus both the previous nuspec-built artifacts and the published 4.2.3 packages
on NuGet.org (the only deltas are legitimate post-4.2.3 source changes and functionally
equivalent SDK-pack formatting).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 16:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 migrates MSTest package creation from hand-authored .nuspec files to SDK-style packing driven by MSBuild logic in the corresponding .csproj files, removing the now-unused nuspecs.

Changes:

  • Switched MSTest.TestFramework and MSTest.TestAdapter packages to custom IncludeBuildOutput=false + TargetsForTfmSpecificContentInPackage/TfmSpecificPackageFile-driven layouts.
  • Switched MSTest.Sdk to pack only its SDK props/targets explicitly (no build output, no dependencies) and deleted the old .nuspec.
  • Removed the *.nuspec and *.NonWindows.nuspec variants for the affected packages.
Show a summary per file
File Description
src/TestFramework/TestFramework/TestFramework.csproj Clarifies the “NotPublishable” core project role in the packaged TestFramework.
src/TestFramework/TestFramework.Extensions/TestFramework.Extensions.csproj Implements SDK-style packing for MSTest.TestFramework with custom layout and post-pack manifest rewrite.
src/TestFramework/TestFramework.Extensions/MSTest.TestFramework.nuspec Deleted (replaced by csproj-driven packing).
src/TestFramework/TestFramework.Extensions/MSTest.TestFramework.NonWindows.nuspec Deleted (replaced by csproj-driven packing).
src/Package/MSTest.Sdk/MSTest.Sdk.nuspec Deleted (replaced by csproj-driven packing).
src/Package/MSTest.Sdk/MSTest.Sdk.csproj Packs only the SDK props/targets explicitly via csproj items.
src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.nuspec Deleted (replaced by csproj-driven packing).
src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.NonWindows.nuspec Deleted (replaced by csproj-driven packing).
src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj Implements SDK-style packing for MSTest.TestAdapter with custom layout and curated dependencies.

Copilot's findings

  • Files reviewed: 9/9 changed files
  • Comments generated: 1

Comment thread src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj Outdated
Evangelink and others added 2 commits June 19, 2026 18:37
The MSTest.TestAdapter localized satellite assemblies were only added when
building the net462 target framework. On non-Windows builds net462 isn't in
TargetFrameworks, so the package would miss buildTransitive/_localization/*.
Select the localization source TFM by OS (net462 on Windows, net8.0 otherwise)
so the satellites are always included.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The MSTest.Analyzers.Package ProjectReference (netstandard2.0) triggered
implicit netstandard facade expansion on the net462 build of
TestFramework.Extensions, copying System.Runtime.InteropServices.RuntimeInformation
and other facades into the output. Those flowed to MSTestAdapter.PlatformServices
and conflicted with the polyfills (CS0436, treated as errors in CI).

Mark the reference ExcludeAssets=compile;runtime (it ships only analyzers and is
never consumed here) and disable ImplicitlyExpandNETStandardFacades on net462. The
MSTest.Analyzers package dependency is still emitted on every TFM group.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 18:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 9/9 changed files
  • Comments generated: 1

_RemoveNonPublishableCoreDependency now only repackages and logs 'Removed...' when the
regex actually stripped the dependency, and fails the build if a 'NotPublishable'
dependency survives the removal attempt (regex no longer matching a changed nuspec
format), so a packaging regression can no longer silently ship an invalid dependency.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

2 participants