Adding a warm-up step to your SharePoint project deploy action
VS.NET 2010 allows a lot of awesome control over the exact steps that occurs when you deploy your project to your development environment.
Figure: VS.NET 2010 Deploy
When you are deploying farm solutions however, it does an IIS Reset, which means when VS.NET says it's done, and you go into your browser to test the site, it sits there for a few minutes warming up.
Fortunately, VS.NET is very extensible, and the community is awesome and has already added many useful extensions.
Grab CKS DEV
To fix this, first grab CKS extensions here: http://cksdev.codeplex.com/
SharePoint Project Properties | SharePoint
You can't edit any of the default configurations, so make your own and add the actions you want.
CKS provides a deployment step "Warm up SharePoint Site (CKSDev)" which will send a request to warm up the SharePoint site that the project deploys to. (see #1 below)
The problem with the CKSDev warm-up step is that the action doesn't actually wait for the site to tell us it's ready, so VS.NET will say "Done", but when you open the browser, it's still not ready
So we add another CKS step "Run PowerShell Script (CKSDev)". See #2 above.
Using a PowerShell step to make sure it is REALLY READY
You then need to look at the properties of the project to see a new property under Deployment.
Point that to a ps1 file in your project directory.
The contents of the ps1 file can be very simple, in 3 lines:
$WebClient = New-Object System.Net.WebClient
$WebClient.UseDefaultCredentials = $true
$Results = $WebClient.DownloadString("http://colt-sp2010/sites/Home/SitePages/default.aspx")
When you deploy now, it will run until the PowerShell step returns.
Activate Features:
Activating feature 'Grid Feature' ...
Run Post-Deployment Command:
Skipping deployment step because a post-deployment command is not specified.
Warm up SharePoint Site (CKSDev):
Run PowerShell Script (CKSDev):
--Executing PowerShell Script #1 'D:\Temp\Grid\warmupsite.ps1'...
--Script 'D:\Temp\Grid\warmupsite.ps1' successfully executed
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========