Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore the connection string parameter in SetParameter.xml

I am using msDeploy (3.0) to deploy my MVC applicaiton. I have a build pipeline that generates build artifacts for msdeploy and my deploy pipeline applies appropriate web.config transforms on the Web.config before deploying it to the production instances. One of the transforms includes changes to connection string. However, looking at the deployed instances, it seems like my web.config transforms are being overriden by the parameters in setParameters.xml in my build artifacts.

Ideal behavior would be that I would be to avoid adding any Connection string to the SetParameter.xml so that all my connection string overrides will be controlled by my deployment pipeline only. How do I achieve that?

Below is a sample of SetParameters.xml file

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

Ideally it would look something like

    <parameters>
       <setParameter name="IIS Web Application Name" value="Default/Foo"/>
   </parameters>

I have already tried passing a parameters.xml file to the msbuild step that does not contain the connectsion string parameter but that did not work

like image 262
KnightFox Avatar asked May 25 '16 19:05

KnightFox


1 Answers

After bang my head against the wall for several hours, I finally figured out the solution. MsBuild takes in a parameter - p:AutoParameterizationWebConfigConnectionStrings=false that prevents the connection strings from being parameterized. Unfortunately, there is little or no documentation on this parameter.

You can also set this on a per project basis adding

      <AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings>

to the PropertyGroup of your build configuration.

like image 192
KnightFox Avatar answered Nov 16 '22 23:11

KnightFox