What does PrivateAssets='All' mean?
Asked Answered
S

1

78

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.

Serle answered 14/12, 2020 at 22:29 Comment(0)
S
73

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>
Serle answered 14/12, 2020 at 22:35 Comment(5)
Thanks a lot, that's great and helped. I discovered, that sometimes the notation in the .csproj is like: <PackageReference Include="PropertyChanged.Fody"> <Version>3.3.1</Version> <PrivateAssets>All</PrivateAssets> </PackageReference> Gender
When I add this fix I have an exclamation mark in Dependencies->Packages->PropertyChanged.FodyNutritious
@Nutritious I'm not sure what you mean. This isn't really a fix but an optional parameter. I can't really help you debug your issue without more information.Serle
@RyanPayne Visual Studio 2022 v17.1.6 -> create new WPF project with .net 6.0 -> add PropertyChanged.Fody nuget -> the warning about PrivateAssets='All' appears -> set PrivateAssets='All' in project project file as described in your answer -> immediately exclamation mark in Dependencies appearsNutritious
@Nutritious interesting. If I were you, I'd post a new Stack Overflow question about the specific issue you're experiencing.Serle

© 2022 - 2024 — McMap. All rights reserved.