开发者

NuGet web.config.transform issue

I'm creating a custom package that needs to modify the web.config file of the destination application, but my config changes never appear in the destination app after installation.

Here's my web.config.transform file:

<?xml version="1.0" encoding="utf-8"开发者_C百科 ?>
<configuration>
  <appSettings>
    <add key="AppInstalled" value="false"/>
  </appSettings>
</configuration>

This key in the appSettings section is never applied.

Here's my nuspec file:

<?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>

Here's the command I run to package the project from the VS 2010 command prompt:

nuget pack mvcapp.csproj

Any Ideas?

Thanks.


The web.config.transform file needs to go into the content folder:

<file src="NuGet\Content\web.config.transform" target="content" />


I know this is an old question, but it's one of the top google results when searching for why a web.config.transform won't apply, so I hope I'm not out of place applying this here.

TLDR; - clear your nuget files from the target project's packages directory (or I assume up the version number) between iterations of testing.

Full Version; I had this problem as well. I could see using NuGet Package explorer that my project was packaged appropriately. I had my web.config.transform under "content", and my libs under their respective lib folders. The dll's were getting deployed, the web.config.transform wasn't getting applied.

The destination project I was testing with was under source control, so I'd add the nuget package, see what happened, then rollback the whole directory. However I didn't notice that the packages folder wasn't under source control, so the folders from my initial package install were in there. I wasn't upping the version number in the package nuspec, either, because I didn't think I had to.

Ultimately I ended up having to clear my nuget package's directory from the project's packages directory, forcing the next nuget install attempt to recreate them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜