.Net Core Nuget Package - 将文件复制到包消费者 wwwroot [英] .Net Core Nuget Package - Copy files to package consumer wwwroot

查看:35
本文介绍了.Net Core Nuget Package - 将文件复制到包消费者 wwwroot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 .Net Core 2.2 库项目.这个项目包含的只是一堆静态文件,这些文件将构建操作"设置为内容.

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.

该项目的唯一目的是构建到 Nuget 包中,并让任何消费者将包含的内容添加到他们的 wwwroot 文件夹中.

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:UsersMyName.nugetpackagemylib.staticfiles.0.1contentFilesany etcoreapp2.2wwwroot.

C:UsersMyName.nugetpackagemylib.staticfiles.0.1contentFilesany etcoreapp2.2wwwroot.

在我的库中,我在 .csproj 文件中使用以下内容:

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.

推荐答案

是的,它不起作用.新方法是链接文件.过去的静态内容和代码文件被复制到目标项目中.但它不再受支持.它被认为是污染"项目.有办法破解它并不完美但有效.检查我的答案 这里.

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.

希望有帮助.

这篇关于.Net Core Nuget Package - 将文件复制到包消费者 wwwroot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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