nuget pack将web.config重命名为web.config.transform

时间:2015-04-14 09:46:12

标签: nuget

我遇到一个问题,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>

提前致谢

克里斯

1 个答案:

答案 0 :(得分:1)

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

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

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

为了完整起见,我的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>