« Previous Next »

Thread: Replacing values in Web.Config without VS2010 + transforms

Last post 07-16-2009 1:41 PM by Roman Kofman. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 07-16-2009, 12:43 PM

    Replacing values in Web.Config without VS2010 + transforms

    I am trying to figure out if it's possible to use the command line msdeploy tool to replace the connectionString while doing a "sync" operation. So far, all I'm finding are references on how to do it within VS2010 with transforms. Is there another way?

     I think it should be possible with replace rules, but I'm struggling with the syntax to make it work. Any help would be appreciated. 

  • 07-16-2009, 1:08 PM In reply to

    Re: Replacing values in Web.Config without VS2010 + transforms

    If you have a connectionstring in a web.config which you are trying to replace such as <connectionStrings>
        <add name="SiteSqlServer" connectionString="Server=(local);Database=applicaition;uid=;pwd=;" providerName="System.Data.SqlClient" />
      </connectionStrings>

    then you can run your sync command as:

    msdeploy  -verb:sync -source:iisApp="Default web site/MyApp" -dest:auto,computername=destination -setParam:type=XmlFile,scope=\\web.config$,match=//connectionStrings/add/@connectionString,value="newconnectionstring"

     All you are specifying is that you are trying to replace a value in an XML file which has to end in the name web.config and for specifying the location of replacement you are providing an xpath. You can read more about setParam here

  • 07-16-2009, 1:41 PM In reply to

    Re: Replacing values in Web.Config without VS2010 + transforms

    Brilliant. All I needed to do was step back and realize I'm just dealing with a simple XML file.

     Thank you!

Page 1 of 1 (3 items)
Microsoft Communities