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:

Add-SPSolution -literalpath c:\VisualWebPartProject1.wsp
Install-SPSolution -identity VisualWebPartProject1.wsp -allwebapplications -gacdeployment
;Verify the solution if installed
Enable-SPFeature -identity VisualWebPartProject1_Feature1 -url http://yoursiteurl/
;Verify feature
Get-SPFeature | Sort-Object DisplayName

Next time around, just Deploy from VisualStudio 2010, switch to the VM and execute this:

Update-SPSolution -literalpath c:\VisualWebPartProject1.wsp -identity VisualWebPartProject1 -GACDeployment

When you modify the solution, SharePoint recycles IIS anyway, so any of those default VisualStudio recycle commands are really superfluous.


3 Responses to Simple SharePoint 2010 Solution deployment

  1. Hi there

    Which registry key’s is it?


  2. vasya10 says:


    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0]

    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.


  3. Thanks a lot for the help, i’ll try it tomorrow.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: