如何防止 NuGet 包中的 HTML 文档文件被复制到内容文件夹
How to prevent HTML documentation files in NuGet package from being copied to content folder
我正在 Visual Studio 2013 年使用在线 "NuGet Packager" 模板构建 NuGet 包。我的项目中有以下文件结构:
content/
docs/
|
+- Install.md
|
+- Install.html
lib/
src/
tools/
作为参考,我安装了 Visual Studio 的 Web Essentials 扩展,docs/Install.md
文件在保存时从 Markdown 编译为 HTML。
使用包含文件的默认 Package.nuspec
设置,docs
目录被复制到 .nupkg 文件的 content
目录。
Package.nuspec 的 <files>
部分:
<files>
<file src="lib\" target="lib" />
<file src="tools\" target="tools" />
<file src="docs\*" target="lib\docs" exclude="docs\**\*.md" />
<file src="content\" target="content" />
</files>
.nupkg 文件的结果文件结构:
content/
docs/
Install.html <-- This is NOT correct
lib/
docs/
Install.html <-- This is correct
package/
tools/
我的 <files>
规范的一些其他变体不起作用:
<file src="content\" target="content" exclude="docs" />
<file src="content\" target="content" exclude="docs\*" />
<file src="content\" target="content" exclude="docs\**\*" />
<file src="content\" target="content" exclude="content\docs" />
<file src="content\" target="content" exclude="content\docs\" />
<file src="content\" target="content" exclude="content\docs\*" />
<file src="content\" target="content" exclude="content\docs\**\*" />
如果我将 docs
文件夹排除在我的 Visual Studio 项目中,此文件夹将不再显示在生成的 content
文件夹中,并像我想要的那样被复制到 lib 文件夹,但这打破了保存 .md 文件并让 Web Essentials 在保存时将其转换为 HTML 的便捷工作流程。
为什么我的 lib/docs
文件夹被复制到 .nupkg 文件中的 content
文件夹?
我讨厌这样做。发布问题 15 秒后我找到了答案。
似乎发生了两件事:
HTML 文件,默认情况下,在 "Content"
的 Visual Studio 中给出 "Build Action"
NuGet 注意到这一点,并将使用此生成操作将任何文件 --- 在项目的任何目录中 --- 放入 .nupkg 文件的 content
文件夹中。
修复:
- Right-click HTML 文件
- 在 "Properties" 窗格中,select "None" 用于 "Build Action"
- 清理并构建项目
我正在 Visual Studio 2013 年使用在线 "NuGet Packager" 模板构建 NuGet 包。我的项目中有以下文件结构:
content/
docs/
|
+- Install.md
|
+- Install.html
lib/
src/
tools/
作为参考,我安装了 Visual Studio 的 Web Essentials 扩展,docs/Install.md
文件在保存时从 Markdown 编译为 HTML。
使用包含文件的默认 Package.nuspec
设置,docs
目录被复制到 .nupkg 文件的 content
目录。
Package.nuspec 的 <files>
部分:
<files>
<file src="lib\" target="lib" />
<file src="tools\" target="tools" />
<file src="docs\*" target="lib\docs" exclude="docs\**\*.md" />
<file src="content\" target="content" />
</files>
.nupkg 文件的结果文件结构:
content/
docs/
Install.html <-- This is NOT correct
lib/
docs/
Install.html <-- This is correct
package/
tools/
我的 <files>
规范的一些其他变体不起作用:
<file src="content\" target="content" exclude="docs" />
<file src="content\" target="content" exclude="docs\*" />
<file src="content\" target="content" exclude="docs\**\*" />
<file src="content\" target="content" exclude="content\docs" />
<file src="content\" target="content" exclude="content\docs\" />
<file src="content\" target="content" exclude="content\docs\*" />
<file src="content\" target="content" exclude="content\docs\**\*" />
如果我将 docs
文件夹排除在我的 Visual Studio 项目中,此文件夹将不再显示在生成的 content
文件夹中,并像我想要的那样被复制到 lib 文件夹,但这打破了保存 .md 文件并让 Web Essentials 在保存时将其转换为 HTML 的便捷工作流程。
为什么我的 lib/docs
文件夹被复制到 .nupkg 文件中的 content
文件夹?
我讨厌这样做。发布问题 15 秒后我找到了答案。
似乎发生了两件事:
HTML 文件,默认情况下,在 "Content"
的 Visual Studio 中给出 "Build Action"
NuGet 注意到这一点,并将使用此生成操作将任何文件 --- 在项目的任何目录中 --- 放入 .nupkg 文件的
content
文件夹中。
修复:
- Right-click HTML 文件
- 在 "Properties" 窗格中,select "None" 用于 "Build Action"
- 清理并构建项目