NuGet web.config.transform 问题
我正在创建一个自定义包,需要修改目标应用程序的 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
有什么想法吗?
谢谢。
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" ?> <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>$idlt;/id> <version>$versionlt;/version> <authors>$authorlt;/authors> <owners>$authorlt;/owners> <licenseUrl>http://mvcapp.codeplex.com/license</licenseUrl> <projectUrl>http://mvcapp.codeplex.com/</projectUrl> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>$descriptionlt;/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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
web.config.transform 文件需要进入内容文件夹:
The web.config.transform file needs to go into the content folder:
我知道这是一个老问题,但在搜索为什么 web.config.transform 不适用时,它是最热门的谷歌结果之一,所以我希望我在这里应用这个不会不合适。
太长了; - 在测试迭代之间从目标项目的包目录(或者我假设版本号)中清除 nuget 文件。
完整版;
我也有这个问题。我可以使用 NuGet Package explorer 看到我的项目已正确打包。我的 web.config.transform 位于“内容”下,我的库位于各自的 lib 文件夹下。 dll 正在部署,web.config.transform 没有得到应用。
我测试的目标项目处于源代码控制之下,因此我添加 nuget 包,看看发生了什么,然后回滚整个目录。但是我没有注意到软件包文件夹不在源代码管理之下,因此我最初的软件包安装中的文件夹就在那里。我也没有提高 nuspec 包中的版本号,因为我认为我没有必要这样做。
最终,我最终不得不从项目的包目录中清除 nuget 包的目录,强制下一次 nuget 安装尝试重新创建它们。
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.