Click here to Skip to main content
Licence CPOL
First Posted 26 Jan 2009
Views 13,741
Bookmarked 6 times

One Web Setup Project for Deploying on Multiple Environments

By Erwin21 | 26 Jan 2009
A solution to create one web setup project for multiple environments

1

2

3
1 vote, 50.0%
4
1 vote, 50.0%
5
4.50/5 - 2 votes
μ 4.50, σa 1.24 [?]

Introduction

A common task in a project is preparing for a deployment. The easiest way to do this is making use of a Web Setup Project. But how do we make this Web Setup Project suitable for multiple environments, because it's most likely that there are environments like Development, Test, Acceptance and Production.

Solution

The key to this solution is the "Condition" property. If you add a file to the Web Setup Project (In the File System view right mouse button on the Web Application Folder, then Add -> File) and select it, you can find the "Condition" property in the properties window.

Solution

We add the following value to the "Condition" property ENV="Prod", this is for the production environment, for the test environment it will be something like this ENV="Test".

We also set the "TargetName" property to Web.Config so the Web Setup Project will output the configuration file as Web.Config.

Well you can add unlimited Web.Config files to your Web Setup Project, they are all output as Web.Config but not all at the same time. So how can we choose the correct Web.Config for your environment, well like this:

%windir%\system32\msiexec.exe /i "Setup.msi" ENV="Prod"
  • msiexec.exe (the Windows installer)
  • /i (is the install switch)
  • "Setup.msi" (compiled output of the Web Setup Project)
  • ENV="Prod" (the condition value)

If you run this, the setup will be started. After the setup is finished, you will notice that only the Web.Config is installed with the "Condition" property set to ENV="Prod".

To make this all fool proof, you can make a shortcut to this command line, like this:

Shortcut

Now when you click on this shortcut, you get the same result.

Conclusion

So with this solution, you can make one Web Setup Project for all your environments and create a better and stable deployment solution.

History

  • 26th January, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Erwin21

Software Developer

Netherlands Netherlands

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralOne tip to avoid including all config files PinmemberMember 40803139:56 4 Feb '09  
GeneralThanks PinmemberMember 40803139:46 4 Feb '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120209.1 | Last Updated 26 Jan 2009
Article Copyright 2009 by Erwin21
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid