Pack MSTest packages from csproj (remove .nuspec)#9259
Open
Evangelink wants to merge 4 commits into
Open
Conversation
…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>
Contributor
There was a problem hiding this comment.
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.TestFrameworkandMSTest.TestAdapterpackages to customIncludeBuildOutput=false+TargetsForTfmSpecificContentInPackage/TfmSpecificPackageFile-driven layouts. - Switched
MSTest.Sdkto pack only its SDK props/targets explicitly (no build output, no dependencies) and deleted the old.nuspec. - Removed the
*.nuspecand*.NonWindows.nuspecvariants 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
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>
_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>
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.
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
NonWindowsvariants).How
IncludeBuildOutput=false+TargetsForTfmSpecificContentInPackage/TfmSpecificPackageFilereproduce the custom per-TFM layout (libvsbuildTransitive, WinUI/UWP variants, localized satellites).build/andbuildTransitive/assets viaNone Pack=true PackagePath(net462/uap gated to Windows builds).ProjectReference:PrivateAssets="none"where assets (analyzers, build targets) must flow to consumers,PrivateAssets="all"for bundled-but-not-dependency assemblies.TestFrameworkproject (PackageId=NotPublishable) is bundled intoliband must keep flowing transitively for downstream compilation, so it can't usePrivateAssets="all". NuGet then emits an invalidNotPublishabledependency thatPackTaskreads from the assets file; a post-pack target strips that single dependency from the producedMSTest.TestFrameworkpackage using built-inUnzip/ZipDirectorytasks.Metadata previously provided by the nuspec (icon,
PACKAGE.mdreadme, license, repository info) is now provided automatically by Arcade /Directory.Build.targets.Verification
Each package was packed (note: desktop
MSBuild.exeis required because of theuap10.0TFM) and compared against:lib/build/buildTransitivefile layouts are identical; dependencies are preserved. The only deltas vs 4.2.3 are legitimate post-4.2.3 source changes (System.Memoryfrom #9209,Parallelize.targetsfrom class-level[Retry]) and functionally-equivalent SDK-pack formatting (extranet8.0-windows/net9.0-windowsdependency groups carrying the same deps,UAP10.0.16299moniker,include="All"attributes).