How to change web.config when running Deploy?

Asked

Viewed 509 times

1

I have an approval and production environment in the cloud but I do Deploy in File System.

I have to enter some parameters and change the connectionString for each of these environments.

Examples of parameters:

  • Information to know when it is approval environment and in this do not send emails to customers, only to test inboxes;
  • Tell the directory where the files should be saved.

Is there any way to change the web config., adding or changing parameters depending on the option of Deploy that I choose?

1 answer

3


You can use the Web.Release.config where changes can be made at the time of publication.

In the link above it has an example of how it works, worth a read, it is very cool.

A practical example of it that I use that is to climb a server only in production is like this:

  <appSettings>
    <add key="RodaServ" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" value="true"/>

Where he changes the key RodaServ for true when it is published.

  • +1 @Ricardo, thanks for the tip. But for both I need to make the Deploy in Release pattern.

  • 1

    See if the second paragraph of step 2 on the link would suit you, I was a little unclear on what exactly you want to do, maybe what he says there will help.

  • 1

    I am terrible in English (by the way, I don’t have English), but if this page were in English it would be better than this translation (rs). But I followed the steps. I added a new Solution Configuration in Solution Manager and gave the name of Homologation. I clicked right over the web. Config and clicked on Add Config Transform and then the web.homologacao.config. Then just add a new Deploy configuration by selecting this new configuration. I added your example parameter change and it worked. Thank you very much!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.