Skip to content

Stop Format redistributing MSBuild #49065

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rainersigwald
Copy link
Member

Bump MSBuild's baseline version to a patched 17.11 and stop having format drop MSBuild assemblies in its folder--they should never be used from there.

MSBuild assemblies are found via MSBuildLocator, and should never be
used from the format folder--so stop droppping them there.
@Copilot Copilot AI review requested due to automatic review settings May 19, 2025 21:48
@rainersigwald rainersigwald requested a review from a team as a code owner May 19, 2025 21:48
Copy link
Contributor

@Copilot 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 stops redistributing MSBuild assemblies by preventing the dotnet-format tool from copying unnecessary MSBuild assets and bumps the MSBuild baseline version to a patched 17.11 release.

  • Updates the dotnet-format.csproj to add PackageReference elements for various Microsoft.Build packages with ExcludeAssets set to runtime, ensuring transitive dependencies do not bring MSBuild assemblies into the distribution folder.
  • Bumps the MicrosoftBuildMinimumVersion in eng/Versions.props from 17.11.4 to 17.11.31 to align with the patched baseline.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/BuiltInTools/dotnet-format/dotnet-format.csproj Added PackageReferences with proper asset exclusions to avoid redistributing MSBuild assemblies.
eng/Versions.props Updated MicrosoftBuildMinimumVersion to reflect the new patched MSBuild baseline.
Comments suppressed due to low confidence (2)

src/BuiltInTools/dotnet-format/dotnet-format.csproj:39

  • Ensure that excluding runtime assets for Microsoft.Build and related packages does not affect any build task behaviors in environments that may require them.
<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" PrivateAssets="All" />

eng/Versions.props:202

  • [nitpick] Document the rationale for updating the MicrosoftBuildMinimumVersion to 17.11.31, ensuring that maintainer instructions and release notes reflect this change.
<MicrosoftBuildMinimumVersion Condition="'$(DotNetBuildSourceOnly)' != 'true'">17.11.31</MicrosoftBuildMinimumVersion>

<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" />
<!-- Suppress transitive dependencies of MSBuildWorkspace on MSBuild to avoid unnecessary copies -->
<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" PrivateAssets="All" />
<PackageReference Include="Microsoft.Build.Framework" ExcludeAssets="runtime" PrivateAssets="All" />
Copy link
Member

@jasonmalinowski jasonmalinowski May 19, 2025

Choose a reason for hiding this comment

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

I would expect this to break this:

Build.Framework.ILogger? binlog = null;
if (binaryLogPath is not null)
{
binlog = new Build.Logging.BinaryLogger()
{
Parameters = binaryLogPath,
Verbosity = Build.Framework.LoggerVerbosity.Diagnostic,
};
}

If it's not for some reason, ExcludeAssets="compile;runtime" might be wise to ensure it's not being used by this code's compilation too.

<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" />
<!-- Suppress transitive dependencies of MSBuildWorkspace on MSBuild to avoid unnecessary copies -->
Copy link
Member

@jasonmalinowski jasonmalinowski May 19, 2025

Choose a reason for hiding this comment

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

@JoeRobich Do we have a tracking bug for your work which might make this unnecessary? Or at least FYI that we can potentially revert this soon enough.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants