web dunia
web dunia

Reputation: 9929

Web.Config Transformation in VS2010

I am working in the web.config transformation file concept. I have three web config. One is Staging, Production, Deployment. I have different connection information for these three.

Web.Config:

  <connectionStrings>
    <add name="MyGallery"
   connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DevelopmentStorageDb;Data Source=BALA\SQLEXPRESS" />
  </connectionStrings>

Web.Config.Production:

<add
    name="MyGallery"
    connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SharePoint_Config;Data Source=BALA\SQLEXPRESS"
    xdt:Transform="Replace" xdt:Locator="Match(name)"
    />

Now I build the code it is working fine. I have created the package. When I run the code in Production mode the new connections string is not taking up.

How can I solve this. Do I need extra effort to move this to somewhere

Upvotes: 4

Views: 4693

Answers (2)

Vishal R Joshi
Vishal R Joshi

Reputation: 781

The naming to be used is Web.Production.Config instead of Web.Config.Production...

Also the more optimal transform to use here is xdt:Transform="SetAttributes(connectionString)" that way the XDT engine will only modify the connectionString attribute and keep the add node as is...

Upvotes: 15

John Saunders
John Saunders

Reputation: 161773

Can you check to make sure the package is being built in the correct configuration (Production)? Can you check to see which web.config gets into the package?

I haven't actually tried this yet.

Upvotes: 0

Related Questions