views:

122

answers:

2

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?

+2  A: 

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.

Nelson
Worth noting that this also stops the config file being copied to output folders for debugging.
Programming Hero
That's correct. The "Build Action" is to not do anything, so any sort of build won't copy it. If you have never built then you won't have a .config file. If you update the file in your project it won't update the build. It could cause you to pull your hair out...
Nelson
A: 

Never publish directly from Visual Studio to a production server!

Publish to a testing server for QA to look at, and then copy from QA to production (for an existing web site with no iis changes, it's just a matter of copying files).

Where I'm at, we also keep these published files under revision control separately, and so when QA signs off on a build the deployment process is simply checking out the files from source control on the production server.

Joel Coehoorn
Actually, that's a good point too. I usually don't copy the web.config to the QA server either since it uses different configuration than during development.
Nelson
DrJokepu
This answer might be good advice, but it does not attempt to answer the actual question.
Sailing Judo
This is a small open source project. I don't have a build server, nor QA :)
ripper234
TeamCity is free for small projects, you could have your dev box be your build server.http://www.jetbrains.com/teamcity/index.htmlNo formatting of comments??
Jason Watts