How to ignore the connection string parameter in SetParameter.xml
Asked Answered
B

1

10

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

Biochemistry answered 25/5, 2016 at 19:26 Comment(0)
B
16

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.

Biochemistry answered 26/5, 2016 at 13:31 Comment(1)
I had the same problem. After my transformation this SetParamters would set back my conections string to what they were in the beginning. Do you have any idea where the values come from? My parameters.xml file does not contain any connectionsstring settingsEvannia

© 2022 - 2024 — McMap. All rights reserved.