PrivateAssets='All' 是什么意思? [英] What does PrivateAssets='All' mean?
问题描述
当我构建我的 .NET Core (NETStandard v2.0) 项目时,我收到以下警告:
When I build my .NET Core (NETStandard v2.0) project I am getting the following warning:
ViewModels:[FodyPackageReference] Fody:PropertyChanged.Fody 的包参考不包含 PrivateAssets='All'
ViewModels: [FodyPackageReference] Fody: The package reference for PropertyChanged.Fody does not contain PrivateAssets='All'
警告参考 PropertyChanged.Fody NuGet 包.
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.
推荐答案
PrivateAssets
是用于控制依赖资产的元数据标签.
PrivateAssets
is a metadata tag used to control dependency assets.
您可能纯粹将依赖项用作开发工具,并且可能不想将其暴露给将使用您的包的项目.在这种情况下,您可以使用 PrivateAssets 元数据来控制这种行为.
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.
在您的情况下,除非您想将 PropertyChanged.Fody
公开给消费者(即您正在发布一个库),否则将 PrivateAssets
设置为 All 将删除警告.
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>
这篇关于PrivateAssets='All' 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!