I have recently started using Web Deploy with IIS 7 on the server and Visual Studio 2012. My project in question is an ASP.Net MVC 3 web application.
I have set it all up correctly and the publishing is working and I get the desired connection string transformation so the target server can access the correct database.
However, there are a couple of appSettings
that need to be different on the server than the values used for development on local machine.
Lets say for this example I have a development web.config with the following:
<appSettings>
<add key="CommonName" value="AlwaysTheSame" />
<add key="VariableName" value="LocalValue" />
<appSettings>
and when it gets published I want it to be as follows on the server:
<appSettings>
<add key="CommonName" value="AlwaysTheSame" />
<add key="VariableName" value="ServerValue" />
<appSettings>
I am thinking I need to change something in the .pubxml
file which is found in the Properties > PublishProfiles
folder as this seems to be how the connection string is changed. However, I am not finding any useful information about how to modify this file to suit my needs. What changes do I need to make?
You could use config transforms, which allow you to have mulitple versions of a config file for different environments:
Then when publishing, you select your environment, and this will override the web.config with the environment-specific config.
In terms of keeping one value consistent across the different deployment types, you could just store that in the main web.config
, and store the others in web.live.config
etc.
For more information of config transforms, read this great blog post by Vishal R. Joshi:
http://blogs.msdn.com/b/webdev/archive/2009/05/04/web-deployment-web-config-transformation.aspx
If you know the values to use on the server in advance, then you can use Web.config transformations.
However, if you require these values to be entered as parameters during the deployment process on the server then you can use Web Deploy parameters as described in this MSDN article.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With