Web.Config Transformations - What to do with connectionString.config if I don’t use Web Deploy?

Asked

Viewed 169 times

3

My Web.config points to an external connectionString file.

<?xml version="1.0"?>
<configuration>
  <connectionStrings configSource="connectionStrings.config"/>
</configuration>

So far no news. Problem is I use Web.Config File Transformation and my deployment process is on File System. I don’t use Web Deploy.

In the Publish screen I have the information that Database Publish is not supported in this Publish method. Summarizing does not work with File System.inserir a descrição da imagem aqui

To solve I thought of creating a connectionString file for testing, homologation and production. In my project then I would have a file connectionString.config, another one called connectionStringProducao.config, another connectionStringHomologacao.config and so on.

And change in Transformation as below:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <connectionStrings configSource="connectionStringsProducao.config" xdt:Transform="Replace"/>
  <system.web>
   //...
  </system.web>
</configuration>

I think it will work, but I think it’s a scam. Someone has a better solution?

1 answer

1

Yes. Publish to local OSI.

  • Install Web Deploy on your local IIS;
  • Create a website on your IIS;
  • Set up a Deploy file (the link contains the steps);
  • Import the file created in your VS;
  • On the database part, mark not to run Migrations, or not to update the base (Update Database);
  • Publish. Check if the file Web.config has been correctly transformed.

Browser other questions tagged

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