Use visual studio2010 web.config is converted after creating a web application

I am using web.config conversions in Visual Studio 2010.

I added the transforms by right-clicking the web.config file and selecting the Add Config Transforms option. To this, I added several configuration files to my solution. After publishing my project via VS2010, my web.config is updated with the selected configuration file (e.g. web.dev.config).

My question is:

Can I update the web.config file with the selected configuration file (for example, web.dev.config) when creating (or after building).

Thanks Mahi

+4
source share
2 answers

I agree with the comments of Pablo. You should not overwrite the web.config file.

If necessary, you can get all the files converted at compile time.

Here's how to do it. Edit the project file (.csproj) and add the code below. Make sure the path is correct.

<Target Name="AfterBuild"> <TransformXml Source="$(SolutionDir)WCFServices\Web.config" Transform="$(SolutionDir)WCFServices\Web.Release.config" Destination="$(OutDir)WebRelease.config" StackTrace="true" /> </Target> 
+2
source

Well, actually one of the goals of the configuration conversions was that the original .config didn't change (I will try to find the MS documentation that mentioned this).

By default, web.config should be your DEV configuration, as it will work both in your environment and during deployment.

And it seems to me that it’s a little better to leave the configuration file unchanged, because if not, you will have problems when working with a control source, for example, with TFS or SVN. You probably want to stay away from the build processes that change the code entry system daily.

+1
source

Source: https://habr.com/ru/post/1414164/


All Articles