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

查看:55
本文介绍了.Net Core Nuget软件包-将文件复制到软件包使用者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:\ Users \ MyName \ .nuget \ package \ mylib.staticfiles \ 0.0.1 \ contentFiles \ any \ netcoreapp2.2 \ wwwroot .

在我的lib中,我在.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软件包-将文件复制到软件包使用者wwwroot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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