In my last post, we looked at how you can publish your .NET Web Application Projects to IIS using Visual Studio and Web Deploy. We did this using the layman’s standard point-and-click. Menu options and buttons, galore.
But what if you want to automate the process? Why waste time clicking around when you could kick back with a calorie-free lemon-lime seltzer and let the machines do what they are good at.
Let’s take a look at how you would accomplish this using the command line, and in particular, PowerShell.
First, set up a variable to make things cleaner.
Next, we’ll clean and build the project using parameters that tell msbuild to publish the app with the profile we created in the last post. The
VisualStudioVersion parameter specifies which version the solution was created in and is necessary for the publishing process.
Now, instead of importing the web deploy package zip in IIS, we’ll use the deploy script that was also generated.
First we run the script with the
/T flag to test the deployment. If this runs with no errors, run the script again with the
You have just deployed your web app using the command line.
Here’s the entire script, modify it to your liking and use it with your automated build server. You are automating your builds…aren’t you?