37

When using the project publish feature in Visual Web Developer Express Edition 2008. How can you exclude publishing the web.config so that it doesn't overwrite the server web.config?

I've tried setting the following in the web.config, which works for any other files ending .config but not the web.config for some reason.

<buildProviders>
  <remove extension=".config" />
  <add extension=".config" type="System.Web.Compilation.IgnoreFileBuildProvider"/>
</buildProviders>
David Glenn
  • 24,412
  • 19
  • 74
  • 94

1 Answers1

75

I can't believe this is so simple but never got answered. I found the answer in this question

Simply select the web.config properties and change 'Build Action' to 'None' and 'Copy To Output Directory' to 'Do Not copy'

Community
  • 1
  • 1
David Glenn
  • 24,412
  • 19
  • 74
  • 94
  • 9
    In Visual Studio 2012, this didn't work. The solution below worked for me. http://blogs.msdn.com/b/webdev/archive/2010/04/22/web-deployment-excluding-files-and-folders-via-the-web-application-s-project-file.aspx I have added *.config to the each of configuration (Release, Debug). – Ibrahim ULUDAG Jun 06 '13 at 06:38
  • 3
    @İbrahimULUDAĞ I did that and on publishing was facing missing/erroneous assembly problems – Arman Bimatov Sep 25 '14 at 20:50
  • 2
    Me too. Adding webconfig to exclusion causes compile problems. – Carlos Landeras Jan 29 '15 at 08:16
  • 1
    Make sure in your publish settings you haven't ticked "delete the entire Internet before uploading my site". – CAD bloke Oct 10 '16 at 08:51