Last post Nov 07, 2013 02:21 PM by Jean1978
Nov 06, 2013 02:06 PM|Jean1978|LINK
Under Visual Studio 2010 you can publish your asp.net web application to another server. Is it possible to publish different versions of a string based on where you are publishing your project.
So for example. When I run the project locally on my system, I have a folder structure of c:\myapp\saved_files. But when I publish to our dev server, that folder structure changes to w:\some_folder\some_app\saved_files.
Currently in my project I constantly have to comment/un-comment a string that contains the appropriate folder information of the system I'm working on. I'm wondering if there is a way to automate this.
I'm thinking something like :
string folder = "w:\some_folder\some_app\saved_files";
string folder = "c:\myapp\saved_files";
Nov 07, 2013 05:52 AM|DarrellNorton|LINK
You can create Web Deploy parameters using XML in your project. See this blog post for an example: http://sedodream.com/2013/03/02/MSDeployHowToUpdateAppSettingsOnPublishBasedOnThePublishProfile.aspx
Or you could specify different build configurations and name your own (for example, DeployToDev and DeployToProd) and use web.config transforms: http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/web-config-transformations
Nov 07, 2013 06:10 AM|mahedee|LINK
Add key in web.config file for different server. I think its bes solution.
<add key="folder" value="w:\some_folder\some_app\saved_files"/>
//Reading appsetting value string folderLocation = ConfigurationManager.AppSettings["folder"];
Nov 07, 2013 02:21 PM|Jean1978|LINK
I'm currently running on VS 2010, so I had to install a service pack to get an updated version of the deployment tool.
That way I was able to use web.config transformations based on my publishing profile.
A simple right click on the pubxml file and "add config transform" was what I needed.
Then I just configured the new web.config file for that profile.
Works like a charm. Thanks.