4

I deploy a project by using build parameters such as:

systemDeployOnBuild = true

system.DeployIISAppPath = [something]

system.DeployTarget = MSDeployPublish

and a few other parameters to target my IIS Web Deploy server.

How can I prevent the web config from being deployed with it?

Thanks!

Base33
  • 3,167
  • 2
  • 27
  • 31
  • Why do you want to skip it? – John Hoerr Jan 28 '13 at 14:33
  • 1
    The web config in the deployment folder contains the correct connection strings and environment settings. – Base33 Jan 28 '13 at 14:47
  • 1
    You might check out [web.config transforms](http://msdn.microsoft.com/en-us/library/dd465318(v=vs.100).aspx). These allow web deploy to modify the web.config for a given environment as it's deploying the site. It's a *good thing* and frees you from one of the more error-prone manual deployment steps. Scott Hanselman talks about it in [this video](http://www.hanselman.com/blog/WebDeploymentMadeAwesomeIfYoureUsingXCopyYoureDoingItWrong.aspx). – John Hoerr Jan 28 '13 at 14:53
  • 2
    When there are dozens of destination environments, maintaining the `web.config` transforms for every single machine gets _tedious_. Furthermore, when you distribute to your clients who self-host via a web deploy package that they must execute, you may not even HAVE the values needed for the transform. Better to exclude the `web.config` completely and let the client edit it himself! – Ross Presser Nov 23 '13 at 00:20

2 Answers2

8

Define property ExcludeFilesFromDeployment. The value is semicolon separated list of files and wildcards to exclude from deployment.

So for exclusion of web config define ExcludeFilesFromDeployment=Web.config

Aleš Roubíček
  • 5,198
  • 27
  • 29
6

Assuming you are using msdeploy via command line you can use -skip parameter as follows:

-skip:objectName=filePath,absolutePath="^.*web\.config$"

In this example I'm using regular expression to exclude all web.configs, but you can also type in relative path to your web.config file.

Alexander Manekovskiy
  • 3,185
  • 1
  • 25
  • 34