【发布时间】:2019-07-09 18:45:48
【问题描述】:
我正在构建一个具有如下文件夹层次结构的 NuGet 包:
ProjectDir
Infrastructure
class1.cs
class2.cs
Task
class3.cs
class3.cs
StuffToInclude
SampleCode
sampleclass1.cs.pp
sampleclass2.cs.pp
Images
image1.gif
image2.gif
Doc
text1.txt
text2.txt
Project.nuspec
注意 nuspec 文件是使用“nuget spec”命令生成的,然后添加以下文件部分:
<files>
<file src="StuffToInclude\**\*.*" target="content" />
</files>
我期望(并且想要)的是包中的内容文件夹,如下所示:
content
SampleCode
sampleclass1.cs.pp
sampleclass2.cs.pp
Images
image1.gif
image2.gif
Doc
text1.txt
text2.txt
我得到的是一个稍大的内容文件夹,其中包含“StuffToInclude”文件夹的第二个副本,如下所示:
content
StuffToInclude
Images
image1.gif
image2.gif
Doc
text1.txt
text2.txt
SampleCode
sampleclass1.cs.pp
sampleclass2.cs.pp
Images
image1.gif
image2.gif
Doc
text1.txt
text2.txt
请注意,不需要的 StuffToInclude 文件夹中没有 SampleCode 子文件夹 - 不知何故,nuget 打包程序发现“.pp”文件不应该放在内容中,除非明确要求。但是所有这些其他文件(在所有其他文件夹中)都是不必要的重复,并且不希望将它们放在那里 - 因为当使用包时,该文件夹也会在目标项目中重复。
我认为 nuspec 中的类似内容可能会有所帮助:
<files>
<file src="StuffToInclude\**\*.*" target="content" exclude="StuffToInclude\**\*.*"/>
</files>
但我为“排除”属性尝试的所有变体似乎都没有帮助。
如何将“StuffToInclude”文件排除在内容文件夹中?
非常感谢。
【问题讨论】:
-
我按照你的步骤得到了你想要的。所以我想也许你在打包过程中犯了一些错误,你能分享更多的.nuspec内容吗?(删除id,作者等个人数据)你使用命令
nuget spec和nuget pack xx.xxspec吗?如果没有,请分享您使用的真实命令。
标签: visual-studio nuget nuget-package nuget-spec