As you may know I am a big fan of automation. I try to automate as many things in my life as possible.
Major reason for automating, is:
I don't have to worry about those "things" anymore, and can focus on other nice "things".
"Things" to automate:
- Entering of timesheets (Should be 1 click at the end of the week… not there yet… It is currently 5 clicks + copy/paste)
- Reminding others to send newsletters
- Handling of money, see Ramits blog post about Automating your Personal Finances
and much more…
Let me know what you automate in your life!
Alright back to software…
Today I want to automate our deployment process:
With 1 button click I want to deploy the latest working version of our software to a certain environment.
In my case that's our Staging environment that we show off to users around Australia.
To give you an idea what I am after
We use mainly Microsoft products and tools to setup this environment. Consisting of:
- Visual Studio 2010 on developers machines
- Team Foundation Server 2010 as Source control, Project management and Build tool
- IIS 7 and SQL Server 2008 R2 as hosting platform
How can I deploy the latest working version from our TFS Build server to Staging?
- Configure the deployment package of your project in VS2010
- Let your Build server create this deployment package for you
- Create a folder on your Build server, for all your deployment batch files
- Configure your settings for your specific environment in "YourProject.SetParameters.xml"
- Create a batch file that launches "YourProject.deploy.cmd"
- Write some info in a file called history.txt about the successful deployment (might come in handy later)
- To Where
- Double click and deploy!!!
1. Configure the deployment package of your project
2. Let your Build server create this deployment package for you
3. Create a folder on your Build server, for all your deployment batch files
Logon to your build server and locate the files necessary for deployment, normally
Create a copy of YourProject.SetParameters.xml and specify your specific parameters for your environment
Create a batch file that launches YourProject.deploy.cmd with the necessary parameters
Append to history.txt some info about the deployment
Here some pitfalls during my journey
- I had to use the parameter -allowUntrusted on msdeploy, because our certificate on the server is unsigned
- Additional I had to use the parameter /A:basic, because I am using HTTP basic authentication over SSL to connect to the Management Service.
Note: Required if the remote server is not using Windows Authentication to identify the user
- Make sure the Management Service is running on the server to deploy
- See if you can deploy from VS2010 to that server, if that doesn't work you should investigate that problem first
- Deployment still fails: Exclude IIS settings in VS2010 and try again
- When something doesn't work and you get:
- System.IO.IOException: The device is not ready
- 401, 404 or 500 HTTP errors
- Run the batch files with msdeploy on the server itself locally to get more debug info
- Check your server logs for more debug info
References for deep dive into this topic
Automating Deployment with Microsoft Web Deploy
Nice blog post about MS Deploy basics
MSDN - ASP.NET Web Application Project Deployment Overview
Common Web Deploy connection errors
How does Web Deployment with VS 10 & MSDeploy Work? from Vishal Joshi
The setup of this automated deployment process is not easy and quick to do, but definitely worth having.
Think of all the hours that you have spent releasing a new version of your app. All these hours are saved in the future, and because this process is automated, it is less error prone.
That leads me to final suggestion.
How do you validate if your deployment was successful?
Make sure to have a zsValidate page, by following Do you have a zsValidate page to make sure your website is healthy?
Next step on my Deployment journey is Continuous Deployment to an internal Dev-test environment. Stay tuned. Should be easy now…
Warning: Don't be afraid of a deep dive with msdeploy