【问题标题】:nuget pack renames web.config to web.config.transformnuget pack 将 web.config 重命名为 web.config.transform
【发布时间】:2015-04-17 22:16:55
【问题描述】:

我有一个问题,即 nuget pack 在我的项目中将 web.config 重命名为 web.config.transform。我正在使用带有 nuspec 文件的 csproj 文件,并且 nuspec 文件中没有行告诉 nuget 重命名文件,但在输出和 nupkg 文件中,web.config 被重命名为 web.config。变换。

web.config 不是项目的一部分,它只是由 nuspec 文件添加(正常情况下,它是由构建过程生成的)

任何人都可以建议它为什么这样做 - 对我来说感觉就像 nuget 中的一个错误,但也许 csproj 文件中有一些东西被 nuget 用作进行重命名的指令?那会是什么?

命令:

nuget pack path\to\projectfile\myproject.csproj -OutputDirectory C:\temp\publish -Version 1.1.646.32517 -Exclude Template.config -Exclude Template.Debug.config -Exclude Template.Release.config -Verbosity detailed

输出:

Attempting to build package from 'myproject.csproj'.
Packing files from 'path\to\projectfile\bin'.
Using 'myproject.nuspec' for metadata.
Add file 'path\to\projectfile\bin\myproject.dll' to package as 'lib\net451\myproject.dll'
Add file ... to package as ...
...
Found packages.config. Using packages listed as dependencies
Id: myproject
Version: 1.1.646.32517
Authors: xxx
Description: myproject
Dependencies: Microsoft.AspNet.WebApi (= 5.2.3)

Added file 'content\ApiTestPage.html'.
Added file ........
.....
Added file 'content\Web.config.transform'.
Added file 'lib\net451\myproject.dll'.

Successfully created package 'C:\temp\publish\myproject.1.1.646.32517.nupkg'.

nuspec 文件:

<?xml version="1.0"?>
<package >
  <metadata>
    <id>$id$</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>$author$</authors>
    <owners>$author$</owners>
    <description>$description$</description>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <releaseNotes>xxx release.</releaseNotes>
    <copyright>Copyright xxx 2015</copyright>
  </metadata>
  <files>
    <file src="bin\*.*" target="content\bin" />
    <file src="web.config" target="content" />
  </files>
</package>

提前致谢

克里斯

【问题讨论】:

  • 找到任何解决方案吗?

标签: nuget


【解决方案1】:

遇到同样的问题,我通过在我的 nuspec 文件中显式添加 Web.config 解决了这个问题。

<package >
  <metadata>
    ...
  </metadata>
  <files>
    <file src="Web.config" target = ""/>
  </files>
</package>

当我第一次发现这个问题时,我还注意到 IIS 现在是从包的根目录而不是 /content 提供服务的,所以我(不情愿地)通过将我的内容移动到包的根目录来解决这个问题。如果您没有这个问题,那么&lt;file src="Web.config" target = "content"/&gt; 可能更适合您。

为了完整起见,我的 nuspec 的文件部分(由于将内容移动到根目录)现在如下。

  <files>
    <file src="Web.config" target = ""/>
    <file src="*.asmx" target = ""/>
    <file src="*.asax" target = ""/>
    <file src="*.html" target = ""/>
    <file src="bin\*.dll" target="bin" />
  </files>

【讨论】:

  • 不幸的是,我们已经有了这个,并尝试了“web.config”和“Web.config”,但都没有为我们解决它。 nuget应该将转换文件放入输出包中是相当奇怪的,所以我的猜测是它在项目文件中。
猜你喜欢
  • 2011-08-11
  • 1970-01-01
  • 2018-12-19
  • 1970-01-01
  • 2018-06-04
  • 1970-01-01
  • 2017-03-04
  • 2016-11-17
  • 1970-01-01
相关资源
最近更新 更多