在NuGet软件包安装中将文件复制到项目中

时间:2020-08-05 09:30:45

标签: c# .net-core nuget

我正在创建一个作为NuGet软件包分发的项目(后端)。 该软件包应在安装时将文件(js,css,vue,json等)添加到使用中的项目。 这是必需的,因为使用方项目应该能够直接使用文件。

两个项目都是 .NET Core .csproj)。

我尝试了以下操作:

  1. 通过contentcontentFiles将文件添加到包中。
  2. init.ps1install.ps1文件添加到软件包中的tools文件夹中。

以上都不是。

将这些文件添加到项目的首选方法是什么? 甚至可以通过安装NuGet软件包来实现?

我有seen可以通过install.ps1 Umbraco CMS 中使用,但这是.NET Framework。


编辑:我现在已经尝试使用* .targets文件了。

这是NuGet软件包的内容:

enter image description here(受RavenDB.Embedded软件包的启发)

这里的问题是,这只会链接到项目中的文件,而实际上没有将它们复制到磁盘上的项目中。

生成的.nuspec文件包含以下项目:

    <contentFiles>
      <files include="any/any/Resources/Countries/countries.de-de.json" buildAction="None" copyToOutput="true" />
      <files include="any/any/Resources/Countries/countries.en-us.json" buildAction="None" copyToOutput="true" />
      <files include="any/any/Resources/Localization/zero.en-us.json" buildAction="None" copyToOutput="true" />
    </contentFiles>

消费解决方案:

enter image description here


编辑2:我想达到这个目标:

(取自here,其中使用了install.ps1

enter image description here

0 个答案:

没有答案