【问题标题】:How to prevent HTML documentation files in NuGet package from being copied to content folder如何防止 NuGet 包中的 HTML 文档文件被复制到内容文件夹
【发布时间】:2016-01-25 15:51:48
【问题描述】:

我正在使用 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/

我的 &lt;files&gt; 规范的一些额外变体不起作用:

<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 文件夹中?

【问题讨论】:

    标签: visual-studio-2013 nuget nuget-package


    【解决方案1】:

    我讨厌这样做。发布问题 15 秒后,我找到了答案。

    似乎发生了两件事:

    1. 默认情况下,HTML 文件在“内容”的 Visual Studio 中被赋予“构建操作”

    2. NuGet 接受了这一点,并将使用此构建操作的任何文件 --- 在项目的任何目录中 --- 放入 .nupkg 文件的 content 文件夹中。

      李>

    解决方法:

    1. 右键单击 HTML 文件
    2. 在“属性”窗格中,为“构建操作”选择“无”
    3. 清理并构建项目

    【讨论】:

      猜你喜欢
      • 2012-11-30
      • 2012-08-18
      • 1970-01-01
      • 1970-01-01
      • 2013-09-03
      • 1970-01-01
      • 2015-02-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多