问题
I have a .Net Core 2.2 Library project. All this project contains is a bunch of static files that have the "Build Action" set as Content.
The sole purpose of this projectis to be built into a Nuget package, and for any consumers to have the included contents added to their wwwroot
folder.
Unfortunately, the files "appear" as if they are there, when looking at Solution Explorer, but they actual path is:
C:\Users\MyName\.nuget\package\mylib.staticfiles\0.0.1\contentFiles\any\netcoreapp2.2\wwwroot
.
In my lib, I am using the following in the .csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<PackageVersion>0.0.6</PackageVersion>
</PropertyGroup>
<ItemGroup>
<Content Include="wwwroot\**" />
</ItemGroup>
</Project>
Having a tough time finding documentation on how this should be done. Any help is appreciated.
回答1:
Yes it is not working. The new way is to link files. Static content and code files used to be were copied to the target project. But it is not supported any more. It is considered "polluting" the project. There is way to hack it is not perfect but works. Check my answer here.
Hope it helps.
来源:https://stackoverflow.com/questions/55287761/net-core-nuget-package-copy-files-to-package-consumer-wwwroot