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

Chr*_*isH 6 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
Run Code Online (Sandbox Code Playgroud)

输出:

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'.
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

提前致谢

克里斯

And*_*ner 1

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

<package >
  <metadata>
    ...
  </metadata>
  <files>
    <file src="Web.config" target = ""/>
  </files>
</package>
Run Code Online (Sandbox Code Playgroud)

当我第一次发现这个问题时,我还注意到 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>
Run Code Online (Sandbox Code Playgroud)