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
Get-SPSolution
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.

Advertisements

SharePoint 2010 installation on Oracle VirtualBox

Imagine your boss tells you in the elevator “Go install SharePoint 2010 and get it ready for development”. What would you really do?

Life is simple with Eclipse: Download, Unzip, Start being productive.

Figuring out the SharePoint 2010 development environment takes a while. Which VM to choose?; how many RAM and disk space are required?; do all developers agree on a single VM?; what CU and patches to apply? In what order?; what KB patches must be applied?; what domain to use?

A plethora of blogs, plus often out-dated docs from Microsoft are prime reasons for confusion. I finally settled on the following environment and the setup was a breeze.

I rate Oracle VirtualBox 3.2.x, formerly Sun VirtualBox, as a better VM with an excellent easy-to-use interface and sound performance. VMWare, Virtual PC/Windows Virtual PC and Hyper-V – all of them need to learn a few things from OpenSource community.

VMWare player is sssssloooooowwww even on the top-of-the-line laptop (i7, 8gb), the UI is not very charming; Windows Virtual PC does not work with 64 bit servers, thank God (SharePoint 2010 is exclusively 64b now, thank God again); And finally Hyper-V: Well, after a day of reading around documentation I still can’t figure what I need to get it working.

Most of my time was spent on weeding out the docs for the actual environment. “Windows Server 2008, Windows Server 2008 R2, SQL Server 2008, SQL Server 2008 R2, Hyper-V Manager, Hypervisor, Hyper-v Server” : All these terms are so overloaded and similar looking and google search brings pretty much everything it can find. Reminds me of Creative product-line. Zen, X-Zen, ZenX, My Zen. Try searching for “Creative Zen” and you pretty much get all the info for all the product lines. Surely a very unintuitive naming of the product. Marketing surely need to understand Naming Convention Paradigms as much as Programmers.

Windows Server 2008 R2 setup was easy. No marks here. SQL Server 2008 R2, little quirky on what to select, but atleast it took care of not having to install all the CUs that I had to deal with SQL Server 2008 SP1.

SharePoint 2010 was easy to install, a little bit of roadblock in setting up the configuration, but very neatly explained in http://mosshowto.blogspot.com/2009/11/installing-sharepoint-2010-windows-2008.html and http://sharepoint.microsoft.com/blogs/fromthefield/Lists/Posts/Post.aspx?ID=112.

Finally installed the Visual Studio 2010 on my host, took more than an hour to install, ho hum, I haven’t played with it much, but I hope it has atleast half the features as Eclipse. Word hiliting atleast is there now, which is a relief.

I wanted to develop SharePoint 2010 solutions on my host OS and just deploy on the guest. By default VirtualBox uses NAT, but I changed it to use Host-only adapter. Restarted VirtualBox and voila, the guest OS IIS is visible from host OS. Earlier versions of VirtualBox had issues doing this. I couldn’t even make it work correctly in Virtual PC.

Overall, the Oracle VB 3.2.8 performance is very good, hibernate and startup time is pretty good too.