关于nuget:如果在nuspec文件中指定了资源,如何在项目中包含内容文件?

How to include content files in project if resources are specified in nuspec file?

我正在创建一个nuget包定义,以包括一堆DLL。其中一些仅在设计时才需要,因此根据《 Nuspec参考》,我创建了一个references部分以指定项目应引用哪些程序集。

我还指定了要包含的文件列表。其中一些文件是库,一个是在安装软件包时执行的PowerShell脚本,另一个是稍后应添加到项目中的内容文件。

这些是我的nuspec文件的相关部分:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
  <metadata>
    <!-- Most of the metadata stuff left out for brevity -->
    <dependencies />
    <references>
      <reference file="MyComponent.dll" />
      <reference file="MyComponent.Data.dll" />
      <reference file="MyComponent.Other.dll" />
    </references>
  </metadata>
  <files>
    <file src="MyPackage.install.ps1" target="tools\\install.ps1" />
    <file src="MyComponent.ReadMe.txt" target="ReadMe.txt" />
    <file src="C:\\Some\\Path\\MyComponent.*.dll" target="lib\
et45" />
    <file src="C:\\Some\\Path\\MyComponent.*.xml" target="lib\
et45" />
    <file src="C:\\Some\\Other\\Path\\*.dll" target="lib\
et45" />
  </files>
</package>

现在这是我的问题:安装软件包时,licenses.licx文件未包含在项目中。要实现此目的,我必须更改什么?

将其添加到references部分不起作用,因为它不是库...


我发现了问题所在。要将文件包含到目标项目中,需要将该文件放置在包的文件夹结构中名为content的子文件夹中:

nuspec文件的正确files部分将如下所示:

1
2
3
4
5
<files>
  <!-- other files omitted for brevity  -->
  <file src="MyComponent.ReadMe.txt" target="content\
eadMe.txt" />
</files>