我正在创建一个作为NuGet软件包分发的项目(后端)。 该软件包应在安装时将文件(js,css,vue,json等)添加到使用中的项目。 这是必需的,因为使用方项目应该能够直接使用文件。
两个项目都是 .NET Core (.csproj
)。
我尝试了以下操作:
content
和contentFiles
将文件添加到包中。init.ps1
和install.ps1
文件添加到软件包中的tools文件夹中。以上都不是。
将这些文件添加到项目的首选方法是什么? 甚至可以通过安装NuGet软件包来实现?
我有seen可以通过install.ps1
在 Umbraco CMS 中使用,但这是.NET Framework。
编辑:我现在已经尝试使用* .targets文件了。
这是NuGet软件包的内容:
这里的问题是,这只会链接到项目中的文件,而实际上没有将它们复制到磁盘上的项目中。
生成的.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>
消费解决方案:
编辑2:我想达到这个目标:
(取自here,其中使用了install.ps1
)