Tuesday 4 June 2013

Deploying an ASP.NET MVC Application using Powershell


Personally, I'm not a big fan of batch files. Don't get me wrong, while batch files are super cool at getting things done, I personally prefer the flexibility that powershell provides.

The script shown below can be used as a template to automate the website deployment process.

I have however assumed that you have MVC installed on the machine. If you do not, then you will need to add the dlls necessary to bin deploy MVC. 
There are a set of assemblies you’ll need to include with your application for it to run properly, unless they are already installed in the Global Assembly Cache (GAC) on the server. Have a look at http://haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx
The script leverages the appcmd utility. You need to be mindful that:
  • When running the script, you may need to set your execution policy.
  • When running this script using other automated deployment environments you may only have access to the command line so you can invoke it like so:
cmd /c powershell -ExecutionPolicy "UnRestricted" .\ApplicationDeployment.ps1 \\Path\To\Binaries\Folder 

A copy of the sample file is available here ... http://sdrv.ms/11UZKW7





No comments:

Post a Comment