Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 2, 2025

Requiring PrivateAssets="all" can break downstream projects that need compile-time references to MSBuild packages. Only PrivateAssets="runtime" is actually needed since ExcludeAssets="runtime" already handles the runtime exclusion.

Changes

  • src/MSBuildLocator/build/Microsoft.Build.Locator.targets - Updated MSBL001 error message to prescribe PrivateAssets="runtime"
  • docs/diagnostics/MSBL001.md - Updated documentation and examples to use PrivateAssets="runtime"

Recommended PackageReference

<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" PrivateAssets="runtime" />
Original prompt

This section details on the original issue you should resolve

<issue_title>MSBuild locator warning should not prescribe PrivateAssets="all"</issue_title>
<issue_description>The new check for ExcludeAssets="compile" is fine, but the error message shouldn't tell the user to set PrivateAssets="all" when in fact only PrivateAssets="runtime" is required, since that can introduce build breaks in referencing packages/projects due to a missing reference assembly to msbuild packages.

Text="A PackageReference to the package '%(_DistinctMSBuildPackagesReferencedPoorly.NuGetPackageId)' at version '%(_DistinctMSBuildPackagesReferencedPoorly.NuGetPackageVersion)' is present in this project without ExcludeAssets=&quot;runtime&quot; and PrivateAssets=&quot;all&quot; set. This can cause errors at run-time due to MSBuild assembly-loading."
</issue_description>

<agent_instructions>Update the detection, the emitted diagnostic message, and the help documentation to move to using PrivateAssets="runtime" instead of PrivateAssets="all"</agent_instructions>

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.

Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Copilot AI changed the title [WIP] Update warning to use PrivateAssets="runtime" instead of all Change PrivateAssets from "all" to "runtime" in MSBL001 diagnostic Dec 2, 2025
Copilot AI requested a review from baronfel December 2, 2025 18:13
Copilot finished work on behalf of baronfel December 2, 2025 18:13
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.

MSBuild locator warning should not prescribe PrivateAssets="all"

2 participants