Devin Gleason Lambert
Devin Gleason Lambert

Reputation: 1730

Trying to replace connectionStrings element for continous deployment in Visual Studio Team Services

I am using Visual Studio Team Services, previously Visual Studio Online, to continuously deploy my web app. I have tried setting up the web.config transformation, I believe it is working after I have changed the configurations setting to Release | Any CPU as instructed here Web config transforms not working with Visual Studio online, VS2013 and Azure .

The issue I believe I am having is more with the transform its self.

Right now I have the following in my web.config

<connectionStrings configSource="connections.config"/>

I want this so I can avoid checking in connections.config and still have my db connections setup locally. What I want to do is replace the above line of code with something like this.

<connectionStrings>
    <add name="umbracoDB" connectionString="blah " providerName="System.Data.SqlClient" />
    <add name="EFdb" connectionString="blah" providerName="System.Data.EntityClient" />
</connectionStrings>

I am using

<connectionStrings configSource="connections.config" xdt:Transform="Remove" xdt:Locator="Match(configSource)"/> and it seems to be successfully removing the configSource connectionStrings element. But I am still confused on how to add back my replacement connectionStrings and add elements?

Devin

Upvotes: 2

Views: 1000

Answers (2)

Harshil Lodhi
Harshil Lodhi

Reputation: 7762

One thing that you can do is to store your DB connection strings as secret variables in Build/Release and then use the Tokenizer task from Marketplace to replace the connection string token with actual string.

Tokenizer task has support for the environments in Release Management.

Upvotes: 2

jrummell
jrummell

Reputation: 43067

If you want to replace your connectionStrings element during deployment, try usign the Replace transform:

<connectionStrings xdt:Transform="Replace">
  <add name="umbracoDB" connectionString="blah " providerName="System.Data.SqlClient" />
  <add name="EFdb" connectionString="blah" providerName="System.Data.EntityClient" />
</connectionStrings>

Upvotes: 1

Related Questions