Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

Extract common packagereferences for MSBuild tasks that ship in the SDK

This PR addresses issue #44768 by extracting common PackageReference declarations from MSBuild task projects into a shared eng/SDKDeliveredMSBuildTask.props file.

Changes Made

Created a new eng/SDKDeliveredMSBuildTask.props file that contains common package references for all MSBuild task assemblies that ship in the SDK, and updated the following projects to import it:

  • Microsoft.NET.Build.Tasks.csproj
  • Microsoft.NET.Sdk.Razor.Tasks.csproj
  • Microsoft.NET.Sdk.StaticWebAssets.Tasks.csproj
  • sdk-tasks.csproj

The shared props file now includes:

Common MSBuild packages (unconditioned):

  • Microsoft.Build.Framework (ExcludeAssets="Runtime")
  • Microsoft.Build.Utilities.Core (ExcludeAssets="Runtime")

Toolset packages (for .NETFramework only):

  • System.Collections.Immutable
  • System.Diagnostics.DiagnosticSource
  • System.Reflection.Metadata
  • System.Reflection.MetadataLoadContext
  • System.Resources.Extensions
  • System.Text.Json

These packages use VersionOverride to ensure compatibility with MSBuild's binding redirects, preventing version conflicts and ensuring that all MSBuild task assemblies use consistent dependency versions.

Benefits

  • Consistency: All SDK MSBuild tasks now use the same package versions
  • Maintainability: Version changes only need to be made in one location
  • Clarity: The shared file documents why these specific versions are required
  • Reduced duplication: Removed duplicate package references across 4 projects

Testing

  • ✅ All affected projects build successfully
  • ✅ No build warnings or errors
  • ✅ No security vulnerabilities detected

Fixes #51444

Original prompt

This section details on the original issue you should resolve

<issue_title>Extract common packagereferences for MSBuild tasks that ship in the SDK</issue_title>
<issue_description>Several projects in this repo build MSBuild task assemblies. They all have clauses in their project file like

<PackageReference Include="System.Collections.Immutable" VersionOverride="$(SystemCollectionsImmutableToolsetPackageVersion)" />
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataToolsetPackageVersion)" />
<PackageReference Include="System.Reflection.MetadataLoadContext" VersionOverride="$(SystemReflectionMetadataLoadContextToolsetPackageVersion)" />

That serve to keep the .NET Framework task unified with the dependencies that MSBuild has. Unfortunately they can differ.

We should extract the concept of "this project builds SDK MSBuild tasks" to an imported SDKDeliveredMSBuildTask.props file that includes the references like that, and import it in the various projects that build tasks.

You can find those projects by searching for SystemReflectionMetadataToolsetPackageVersion and other properties to make sure you've found them all.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Extract common packagereferences for SDK MSBuild tasks Extract common PackageReferences for MSBuild tasks that ship in the SDK Oct 24, 2025
Copilot AI requested a review from rainersigwald October 24, 2025 18:35
Copilot finished work on behalf of rainersigwald October 24, 2025 18:35

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataToolsetPackageVersion)" />
<PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonToolsetPackageVersion)" />
Copy link
Member

Choose a reason for hiding this comment

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

@copilot include these and any other *ToolsetPackageVersion reference in the new .props file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in f4d9a77. Added System.Text.Json, System.Diagnostics.DiagnosticSource, and System.Resources.Extensions to the shared props file and removed them from the individual project files.

Copilot AI requested a review from rainersigwald October 24, 2025 18:49
Copilot finished work on behalf of rainersigwald October 24, 2025 18:49
Comment on lines 17 to 19
<PackageReference Include="Microsoft.Build" />
<PackageReference Include="Microsoft.Build.Tasks.Core" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
Copy link
Member

Choose a reason for hiding this comment

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

@copilot In these MSBuild-task projects, also pull out the unconditioned references to the packages

  • Microsoft.Build
  • Microsoft.Build.Framework
  • Microsoft.Build.Tasks.Core
  • Microsoft.Build.Utilities.Core

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 9c9db97. Added Microsoft.Build.Framework and Microsoft.Build.Utilities.Core to the shared props file and removed them from all four MSBuild task projects. Also removed the duplicate System.Text.Json reference from Microsoft.NET.Build.Tasks.csproj that was conflicting with the toolset version from the shared props.

Copilot finished work on behalf of rainersigwald October 24, 2025 19:31
Copilot AI requested a review from rainersigwald October 24, 2025 19:31
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