.Net Core Nuget Package - Copy files to package consumer wwwroot

喜你入骨 提交于 2021-01-28 11:50:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!