From e16c8ddfde798a46989c38ddcaf41592933130bd Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 2 Dec 2025 18:04:57 +0000
Subject: [PATCH 1/2] Initial plan
From 5d37c16f69ad03b786a2bf92e09fab49c6bba8e4 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 2 Dec 2025 18:10:44 +0000
Subject: [PATCH 2/2] Change PrivateAssets from "all" to "runtime" in warning
and docs
Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
---
docs/diagnostics/MSBL001.md | 14 +++++++-------
.../build/Microsoft.Build.Locator.targets | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/docs/diagnostics/MSBL001.md b/docs/diagnostics/MSBL001.md
index b98f1ef..4e27b6c 100644
--- a/docs/diagnostics/MSBL001.md
+++ b/docs/diagnostics/MSBL001.md
@@ -2,7 +2,7 @@
## Error Message
-> A PackageReference to the package '{PackageId}' at version '{Version}' is present in this project without ExcludeAssets="runtime" and PrivateAssets="all" set. This can cause errors at run-time due to MSBuild assembly-loading.
+> A PackageReference to the package '{PackageId}' at version '{Version}' is present in this project without ExcludeAssets="runtime" and PrivateAssets="runtime" set. This can cause errors at run-time due to MSBuild assembly-loading.
## Cause
@@ -16,7 +16,7 @@ When MSBuild runtime assemblies are copied to your application's output director
2. **Missing SDKs and build logic**: The MSBuild assemblies in your output directory don't include the SDKs, targets, and build logic needed to build real projects
3. **Inconsistent behavior**: Your application may behave differently than `MSBuild.exe`, `dotnet build`, or Visual Studio when evaluating projects
-Additionally, without `PrivateAssets="all"`, downstream projects that reference your project may still get these runtime assets transitively, causing the same issues in consuming projects.
+Additionally, without `PrivateAssets="runtime"`, downstream projects that reference your project may still get these runtime assets transitively, causing the same issues in consuming projects.
## Example Runtime Error
@@ -36,19 +36,19 @@ This happens because your application loads MSBuild assemblies from your bin fol
## Solution
-Add `ExcludeAssets="runtime"` and `PrivateAssets="all"` to all MSBuild PackageReferences in your project file:
+Add `ExcludeAssets="runtime"` and `PrivateAssets="runtime"` to all MSBuild PackageReferences in your project file:
```xml
-
-
-
+
+
+
...
```
- `ExcludeAssets="runtime"` tells NuGet to use these packages only for compilation, not at runtime. At runtime, MSBuildLocator will load MSBuild assemblies from the registered Visual Studio or .NET SDK installation.
-- `PrivateAssets="all"` prevents the package reference metadata from flowing to downstream projects, ensuring that projects referencing your library don't inadvertently get runtime assets from these packages.
+- `PrivateAssets="runtime"` prevents the runtime assets from flowing to downstream projects, ensuring that projects referencing your library don't inadvertently get runtime assets from these packages. Using `"runtime"` instead of `"all"` allows downstream projects to still reference the compile-time assemblies if needed.
## Alternative: Disable the Check (Not Recommended)
diff --git a/src/MSBuildLocator/build/Microsoft.Build.Locator.targets b/src/MSBuildLocator/build/Microsoft.Build.Locator.targets
index f110be0..b37ad22 100644
--- a/src/MSBuildLocator/build/Microsoft.Build.Locator.targets
+++ b/src/MSBuildLocator/build/Microsoft.Build.Locator.targets
@@ -19,7 +19,7 @@