Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does PrivateAssets='All' mean?

When I build my .NET Core (NETStandard v2.0) project I am getting the following warning:

ViewModels: [FodyPackageReference] Fody: The package reference for PropertyChanged.Fody does not contain PrivateAssets='All'

The warning is in reference to the PropertyChanged.Fody NuGet package.

While the warning does not stop the build, I would like to resolve the warning. However, I don't understand what it is trying to communicate.

like image 874
Ryan Payne Avatar asked Dec 14 '20 22:12

Ryan Payne


People also ask

Where are NuGet references stored?

The location of the default global packages folder. The default is %userprofile%\. nuget\packages (Windows) or ~/.

What is a NuGet package?

Put simply, a NuGet package is a single ZIP file with the . nupkg extension that contains compiled code (DLLs), other files related to that code, and a descriptive manifest that includes information like the package's version number.


1 Answers

PrivateAssets is a metadata tag used to control dependency assets.

You might be using a dependency purely as a development harness and might not want to expose that to projects that will consume your package. In this scenario, you can use the PrivateAssets metadata to control this behavior.

Package references (PackageReference) in project files

In your case, unless you want to expose PropertyChanged.Fody to a consumer (i.e. you are releasing a library), setting PrivateAssets to All in your .csproj file will remove the warning.

<Project Sdk="Microsoft.NET.Sdk">     <ItemGroup>       <PackageReference Include="PropertyChanged.Fody" Version="3.3.1" PrivateAssets="All" />     </ItemGroup> </Project> 
like image 115
Ryan Payne Avatar answered Oct 02 '22 15:10

Ryan Payne