Converting a SharePoint 2007 solution to SharePoint 2010 is straightforward. In fact, other than recompiling the Visual Studio project with the SharePoint 2010 DLLs, you do not have to do anything else at all. When it comes to deploying the solution in SharePoint 2010, you can deploy it as a farm solution or a sandboxed solution. A farm solution is the same as a SharePoint 2007 solution; it is scoped to the farm level and operates with full trust. A sandboxed solution is scoped to a site collection and is limited in capabilities, but it offers certain benefits to both farm administrator and developers. The distinction between a farm and sandboxed solution lies in the deployment process, not in the solution package (which is the same in both cases).
After recompiling a project for SharePoint 2010, I was able to deploy it successfully as a farm solution. I then attempted to deploy the same solution package as a sandboxed solution. The first step was to add the solution package to the solution store with the following PowerShell cmdlet:
However, this immediately resulted in the following error:
Add-SPUserSolution : The manifest.xml file could not be found within “SoftArtisansTutorial.wsp”.
The manifest lists the solution files and is obviously required. However, I verified that it was contained in the solution package and moreover the same package had successfully been deployed as a farm solution.
I examined the solution package by opening it with an archiving program (Winrar), since the solution package (.wsp) is just a cabinet file. I noticed that the manifest.xml file, along with other files at the root level, were all pre-prepended with a “.” path, as shown below.
The “.” path is not unusual because it indicates the current directory. However, a different solution package which had been successfully deployed as a sandboxed solution did not contain the path.
The solution package was generated with the makecab.exe utility from a DDF file, which contained the following entry:
From the DDF file, makecab.exe automatically generated an INF file which contained the following entry:
It turned out that the “.” path was the culprit. This was unexpected because, as noted, the same solution was already deployed as a farm solution. The fix is to simply remove the line “.Set DestinationDir=.” from the DDF file. This line is unnecessary since by default makecab.exe places a file at the root directory of the package. When opened in Winrar, the resulting solution package appears as follows.
I was then able to deploy it successfully as a sandboxed solution.
- Paul Stubs has a terrific overview of Sandbox Solutions
- Waldek Mastykarz wrote about SharePoint 2010 page Components in Sandboxed Solutions
- And here’s a nice little powershell script from Not Defteri for enabling Sandbox Solutions on a Domain Controller