Thursday, February 28, 2013

Web Deploy Check list for deploying website to IIS7 from Visual Studio and TFS

Web Deploy is one of the mechanisms to publish websites to IIS from Visual Studio.  You can utilize this mechanism to publish from Visual Studio, TFS or manually if you have existing website packaged as a zip file.  If you haven’t checked this gem of resources (Vishal Joshi's Blog) on web deploying and publishing then please do yourself a favor.  In this post I am going to talk about a checklist to make sure before you wish to publish site to IIS.  Here is the list:

  • Installed the latest Web Deploy on windows server (Check this IIS website).  
  • Web Management Service is started and running
  • Web Deployment Agent Service started and running
  • Created a website inside IIS and created application pool for it  
  • Given the user IIS Manager Permissions at the site level inside IIS
  • Configured website for Web Deploy publishing
  • Saved Web publish settings on a local desktop
  • Import Web publish settings from the local desktop from Visual Studio publish dialog
  • Publish url is over Https 
  • Checked connectivity to the site from the Visual Studio publish dialog 

Now before you jump on to the TFS side of things to publish, please make sure that you have done following things:

  • Team Foundation Server Build service account is added to IIS Manager Permission section for the website inside IIS
  • Able to publish successfully from visual studio using web deploy?
  • Check the MSBuild parameters for web deploy (I have provided what works for me below).
If you have some more checklist you have formed over the years then let me know I will add to this list.

What-If-Error
When you click publish from visual studio you will have to select a publish method and at that point select Web Deploy.  You have the option to import the profile you have created from that publish dialog.  This will pre-populate all the details.  You will have to provide the user name and password for the user who has the permission in IIS Manager Permissions as described in earlier.  At this point if you see any errors then this is a nice website where all the errors are listed.  I think you will see these errors only if you do some mistake while manually typing out the details in the publish dialog.  I haven’t found any issues if you import site details through import mechanism.

Here are TFS MSBuild parameters I use to publish a website from TFS to IIS7.

/p:DeployOnBuild=True
/p:DeployTarget=MsDeployPublish
/p:CreatePackageOnPublish=True
/p:MSDeployPublishMethod=WMSVC
/p:MSDeployServiceUrl=https://ServerName:8172/MSDeploy.axd /p:DeployIisAppPath="NameofWebsiteOnIISServer"
/p:AllowUntrustedCertificate=True
/p:UserName="domain\serviceaccount"
/p:Password="AwesomeSecurePassword"

If you are still unsuccessful in publishing the website from TFS Build then it could be that your TFS Build server is 2010 and you are using Visual Studio 2012 and it might be missing some binaries.  If you install Visual Studio 2012 on the build server then this issue could be resolved.