Skip to content

Commit da8ccd2

Browse files
authored
Update MSBL001.md with PackageReference guidance for transitive package references (#369)
Added notes on handling MSBL001 errors and PackageReference management.
1 parent c6d13f2 commit da8ccd2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/diagnostics/MSBL001.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ Add `ExcludeAssets="runtime"` and `PrivateAssets="all"` to all MSBuild PackageRe
5050
- `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.
5151
- `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.
5252

53+
> [!NOTE]
54+
> Make sure that you don't add `ExcludeAssets` and `PrivateAssets` to the `Microsoft.Build.Locator` `PackageReference` itself - you need its run-time assets in order to use it!
55+
56+
### What if I get errors for PackageReferences I don't have?
57+
58+
It's possible that you may get `MSBL001` errors for packages that you don't directly reference - these packages are _transitive_ references, pulled in by other packages you _do_ reference.
59+
To solve this, you'll need to add new PackageReference items to your project and add the ExcludeAssets/PrivateAssets metadata onto them. In the future we hope to have the ability to 'flow' this metadata from a parent PackageReference to transitive PackageReferences so that you don't need to do this.
60+
5361
## Alternative: Disable the Check (Not Recommended)
5462

5563
If you need to distribute MSBuild assemblies with your application (not recommended), you can disable this check by setting the following property in your project file:

0 commit comments

Comments
 (0)