Mixing web.config transforms and Parameters.xml, or something to that effect
Asked Answered
J

2

7

I've been using web.config transforms for a while now, for deployment on a few of our projects. What I'm now trying to achieve, is to have Web Deploy's 'Import Package' screen to prompt to check & update several of the variables in , adjusted for each environment.

I know I can use Parameters.xml to introduce these editable variables, but I haven't yet found how to have the defaults updated for different environment targets.

Consider the following neat, but non-overlapping example of wanting to have the user edit the 'specialServer' AppSetting, and have it present a different default when compiled for the NewEnv target:

Sample entry in Parameters.xml:

<parameter name="Special server" description="" tags="" defaultValue="server1-dev.domain">
    <parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/appSettings/add[@key='specialServer']/@value" />
</parameter>

Sample transform for Web.NewEnv.config, setting a different value for

<appSettings>
    <add key="specialServer"
        value="other-server.domain2"
        xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
</appSettings>

Sample of the prompt in Web Deploy:

enter image description here

Any suggestions as to how to update the default value for different build targets?

Thanks.

Janot answered 25/7, 2012 at 7:0 Comment(0)
A
1

You would have to generate and new parameters definition file and embed it in your WebDeploy package for each environment.

This would give you different deploy packages per environment and would allow you to specify different default values for those parameters. Obviously doing so undermines the point if parameter transforms and you essentially end up baking in your config, but it's the only way to achieve what you want.

I don't recommend the approach but it may fit your needs.

Atwitter answered 21/1, 2014 at 8:24 Comment(0)
D
1

We use a batch script to call msdeploy. It allows for a parm to specify the Parameters.xml file. Then with multiple Parameters.xml files (one per environment), you can just call msdeploy like:

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:package='D:\mysite.zip' -dest:auto,computerName="testcomp1",includeAcls="False" -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"D:\mysite.test.SetParameters.xml"

Depressomotor answered 24/7, 2017 at 16:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.