Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent 'Publish Web' from overwriting config files?

When I publish my Asp.Net MVC website to the production server (via VS2008), the web.config & castle.xml files are overwritten. The content of these files is obviously different between my local dev environment and the production server.

How do I prevent these files from being published?

like image 493
ripper234 Avatar asked May 11 '10 17:05

ripper234


People also ask

How do I stop inheriting parent Web config?

In order to prevent root settings to be inherited, use inheritInChildApplications attribute in location tag. The location path in the example above is empty. It means that this setting will be applied to the level of the config file and below it.

Does Web config override machine config?

The machine. config file file is at the highest level in the configuration hierarchy while Web. config file is to override the settings from the machine. config file.

Can we have two Web config files for a web application?

Yes you can have two web. config files in application. There are situations where your application is divided in to modules and for every module you need separate configuration. For example if you have a application which has two modules lets say accounts and sales.

Does changing the web config recycle the app pool?

When you edit the web. config, It will restart the AppDomain (NOT AppPool) of that web application and clears the all occupied resources and memory. So other web applications running under that App Pool will not be affected.


1 Answers

In Visual Studio solution explorer, go to your web.config file's properties. Make sure "Build Action" is "None" and "Copy to Output Directory" is "Do not copy".

If you ever want to update it in the future you'll have to do it manually or change "Build Action" back to "Content". The next time you build (or publish) it will overwrite it.

like image 67
Nelson Rothermel Avatar answered Oct 05 '22 06:10

Nelson Rothermel