How can I exclude web.config when publishing in Visual Studio 2013?
When using the Publish Web Site feature in Visual Studio 2013. How can you prevent the publication of the web.config so that it does not overwrite the web.config server?
The question is identical to the following, except for the VS version.
How do I exclude web.config when publishing to Visual Web Developer Express?
However, his solution does not apply to VS2013. "Build Action" option cannot be found in VS2013. And setting "ExcludeFilesFromDeployment" causes compilation problems.
source to share
Excluding the web.config file is not the recommended solution. Instead, you should use the web.config transform file, which is the web.xxx.config file.
When you publish your site, Visual Studio will merge your local web.config with the corresponding web.xxx.config file
The configuration configuration file uses XDT (XML Document Transform) syntax. For example, if you want to change your connection string, you can use this piece of code in your transform file:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="MyDB"
connectionString="value for the deployed Web.config file"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
See Web.config Transformation Syntax for Deploying Web Projects with Visual Studio for more examples and information.
source to share