使用.NET标准库.csproj时,如何将NuGet contentFiles CopyToOutput设置为true? [英] How do you set NuGet contentFiles CopyToOutput to true when using a .NET Standard library .csproj?

查看:67
本文介绍了使用.NET标准库.csproj时,如何将NuGet contentFiles CopyToOutput设置为true?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找任何方法来将包含在.NET标准库项目中VS2017中内置的NuGet包中的内容文件的CopyToOutput属性设置为true.

I've been looking for any way to set the CopyToOutput attribute to true for content files I'm including in a NuGet package built in VS2017 from a .NET Standard Library project.

使用内容"节点添加文件时,我可以看到包中的文件,但是当查看在本地缓存时被拉出的nuspec时,没有CopyToOutput,因此默认情况下为false.在这种情况下,当它在ASP.NET Core站点中被引用时,不会将任何内容复制到应用程序中.如果我手动更新该缓存版本以包括该属性并将其设置为true并还原,则所有内容都会被复制.

When adding the files using the Content node, I can see the files in the package, but when looking at the nuspec that is pulled out when it's cached locally, there is no CopyToOutput, so it's false by default. In this case, when it's referenced in an ASP.NET Core site, nothing is copied into the application. If I manually update that cached version to include the attribute and set it to true and restore, everything gets copied.

不幸的是,我调查了Nuget.Build.Tasks.Pack.dll,看来没有办法通过MSBuild属性传递该值.

Unfortunately, I looked into the Nuget.Build.Tasks.Pack.dll and it looks like there's no way to pass that value through an MSBuild property.

有人遇到这个问题并且有解决方法吗?

Did anybody run into this issue and has a workaround?

推荐答案

请参阅以下请求请求:

See this pull request: Allow specifying copyToOutput and flatten as Metadata on Content items when packing sdk csproj #1450

您需要在源csproj中将内容的 PackageCopyToOutput 设置为true.

You'll need to set PackageCopyToOutput to true in the source csproj for the content.

<Content Include="...">
    <PackageCopyToOutput>true</PackageCopyToOutput>
</Content>

,一旦构建了程序包,它将包括CopyToOutput ="true".内容.

and once build the package, it will include CopyToOutput="true" for that content.

这篇关于使用.NET标准库.csproj时,如何将NuGet contentFiles CopyToOutput设置为true?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆