msbuild - 如何忽略SetParameter.xml中的连接字符串参数

标签 msbuild web-config msdeploy web.config-transform

我正在使用msDeploy(3.0)部署我的MVC应用程序。我有一个生成管道,用于为msdeploy生成生成工件,并且我的部署管道在将它部署到生产实例之前,在Web.config上应用了适当的web.config转换。转换之一包括对连接字符串的更改。但是,查看已部署的实例,似乎我的web.config转换已被我的构建工件中的setParameters.xml中的参数覆盖。

理想的行为是,我将避免将任何Connection字符串添加到SetParameter.xml中,以便所有连接字符串替代都仅由我的部署管道控制。我该如何实现?

以下是SetParameters.xml文件的示例

    <parameters>
       <setParameter name="IIS Web Application Name" value="Default/Foo"/>
       <setParameter name="Foo-Web.config Connection String" value="Server=Foo,1433;Database=Bar;Integrated Security=SSPI;MultiSubnetFailover=True;App=Something;Connection Timeout=25"/>
   </parameters>

理想情况下,它看起来像
    <parameters>
       <setParameter name="IIS Web Application Name" value="Default/Foo"/>
   </parameters>

我已经尝试过将parameters.xml文件传递给不包含连接字符串参数但无法正常工作的msbuild步骤

最佳答案

在将我的头撞在墙上几个小时之后,我终于找到了解决方案。 MsBuild接受一个参数-p:AutoParameterizationWebConfigConnectionStrings = false,以防止参数化连接字符串。不幸的是,关于此参数的文档很少或没有。

您还可以基于每个项目进行设置,添加

      <AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings>

到构建配置的PropertyGroup。

关于msbuild - 如何忽略SetParameter.xml中的连接字符串参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37445980/

相关文章:

windows-services - MsDeploy runCommand 需要提升的权限?

svn - 在Jenkins Pipeline中构建特定的修订版

.net - 在构建时注入(inject)程序集版本号

visual-studio-2010 - MSBuild/VS2010 : How to reference "RuntimeLibrary" compiler setting in a VS2010 "Property Sheet"

asp.net-mvc - xdt :Transform ="Insert" not working for <rewrite> in <system. 网络服务器>

msdeploy - 是否将整个包上传到 MsDeploy.axd?

visual-studio - (Wix) heat.exe 无法用 msbuild 加载

.net - URL 重写 - 删除 .html 扩展名

asp.net - 如何在Web.Config中禁用目录浏览

iis - 用于跳过 web.config 文件的 WebDeploy 命令行工具