Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

asp.net core - How do you set NuGet contentFiles CopyToOutput to true when using a .NET Standard library .csproj?

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.

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.

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 Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...