NuGet web.config.transform问题

Kah*_*anu 9 asp.net-mvc transform nuget

我正在创建一个需要修改目标应用程序的web.config文件的自定义程序包,但我的配置更改在安装后永远不会出现在目标应用程序中.

这是我的web.config.transform文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="AppInstalled" value="false"/>
  </appSettings>
</configuration>

appSettings部分中的此键永远不会应用.

这是我的nuspec文件:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata>
    <id>$id$</id>
    <version>$version$</version>
    <authors>$author$</authors>
    <owners>$author$</owners>
    <licenseUrl>http://mvcapp.codeplex.com/license</licenseUrl>
    <projectUrl>http://mvcapp.codeplex.com/</projectUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>$description$</description>
    <tags>mvc app</tags>
  </metadata>
  <files>
    <file src="\bin\Release\MvcApp.MVC3.dll" target="lib" />
    <file src="NuGet\Content\ajax-loader.gif" target="Content" />
    <file src="NuGet\Content\web.config.transform" target="web.config" />
    <file src="NuGet\Views\Install\Index.aspx" target="Views\Install\Index.aspx" />
  </files>
</package>

这是我从VS 2010命令提示符运行打包项目的命令:

nuget pack mvcapp.csproj

有任何想法吗?

谢谢.

dav*_*owl 21

web.config.transform文件需要进入内容文件夹:

<file src="NuGet\Content\web.config.transform" target="content" />
Run Code Online (Sandbox Code Playgroud)

  • 是的,这只是我在我的nuspec文件中发现的问题之一.我再次查看了文档并使用删除了nuspec文件中的"files"元素,并使用带有nuspec文件的文件夹下的/ lib和/ content文件夹的NuGet约定.它对我来说效果更好.谢谢. (3认同)