Simple SharePoint 2010 Solution deployment

Here are some useful PowerShell commands for simple SharePoint 2010 deployment. This article is for those who are learning SharePoint and not for the SPGurus.

I keep my SharePoint 2010 in a VM (Oracle VirtualBox) and Visual Studio 2010 on the host. Its just easy to work with IDEs on the host rather than VM. That way, when a code inspiration strikes you, it will not fade away until the VM opens up. Also, Visual Studio 2008 had this annoying-much-complained-about-screen-flickering issue when working from within a VM (atleast Windows Virtual PC). Not sure if it went away for VS 2010.

Anyway, I was disappointed to see Visual Studio 2010 cannot create SharePoint projects if SP 2010 Server is not installed on the same machine. Dumb move. Very dumb. And the workaround? Simply export the “14” registry key from a SP2010 Server and import into local machine. Your local machine thinks you have SharePoint Server, but you really only installed a Name of the Server. Now VS 2010 allows you to create a project, but you have the itch to click that Validate button, isnt it? Well, survive the itch and just press Finish and the SharePoint project is now created. Go figure! Microsoft could have had some brownie points making this feasible out of the box.

Next, you cannot deploy a wsp directly into the VM. And the workaround? Deploy the solution locally, copy it to a shared directory, use PowerShell within the VM and deploy. Could have been made simple… Er, Could…Er.

Let us assume you created the simplest “Please-start-with-me” project – VisualWebPart1. Here are some powershell commands and shortcuts to make this deployment simple:

Edit the project properties and create a new deployment configuration, which does only Pre-command Line and Post command Line. In the Post-Command Line text box, add a dos command to copy the wsp file to a shared folder with VM.

For the first time, you need to execute the following commands in PowerShell for SharePoint.

Catch: This is not the regular Windows 2008 PowerShell, but the SharePoint Management PowerShell, located within the SharePoint Programs shortcuts:

You can export the whole section from regedit and import them into windows 7.

But you cannot do integrated debugging from Windows 7, unless you do remote attach process etc. which is very cumbersome. After sometime, I have abandoned developing on Windows 7 (while having the SP on VM… you can still try having SP2010 on Windows 7 itself, but thats a different situation) and do it directly on the Server, mainly because of the integrated debugging capabilities.