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

时间:2015-02-03 09:49:34

标签: nuget nuget-package nuget-spec

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

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

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

<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\net45" />
    <file src="C:\Some\Path\MyComponent.*.xml" target="lib\net45" />
    <file src="C:\Some\Other\Path\*.dll" target="lib\net45" />
  </files>
</package>

现在我的问题是:在安装软件包时,licenses.licx文件不会包含在项目中。我必须改变什么来实现这一目标?

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

1 个答案:

答案 0 :(得分:2)

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

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

<files>
  <!-- other files omitted for brevity  -->
  <file src="MyComponent.ReadMe.txt" target="content\ReadMe.txt" />
</files>
相关问题