Monday, August 9, 2010

Creation of Solution Packages in Sharepoint 2010

Creating the Solution Package
 
A solution package is a CAB file with a .wsp filename extension that contains all the files that must be deployed on servers in the farm.
 
The first step in creating a solution package is to create manifest.xml. The second step is to create a Data Directive File (.ddf) that instructs the MAKECAB.EXE command-line utility what files to include in the output CAB file. The last step is to use MAKECAB.EXE to compile the CAB file.
 

To create the manifest for a solution package

  1. Open Visual Studio as an administrator by right-clicking the program in the Start menu and selecting Run as administrator.
  2. Open the project that contains the code for your rule.
  3. Create a Solution folder.
    In Solution Explorer, right-click the project name, choose Add, and choose New Folder. Type Solution.
  4. Create a solution manifest file.
    Right-click the Solution folder, choose Add, and then choose New Item.... In the Add New Item dialog, select the XML File template. Name the filemanifest.xml. Then click Add.
  5. Open manifest.xml in the editor.
  6. Delete the first (and only) line in the file. In its place, paste the following code.

              xmlns="http://schemas.microsoft.com/sharepoint/">
     
       
     

     
       
                  Location="AssemblyName.dll" />
     
  7. Replace the value of the SolutionId attribute with a newly generated GUID (without braces).
    You can use the GuidGen Tool (guidgen.exe) to get a new GUID. On the Tools menu in Visual Studio, choose Create GUID. In the Create GUID dialog, select4. Registry Format, then click Copy. Paste the content of the clipboard between the quotation marks after the SolutionId attribute. Remove the braces from the GUID.
  8. Modify the value of the FeatureManifest element’s Location attribute, replacing “FeatureFolderName” with the name of the folder in your solution that contains the feature.xml file.
    When the solution is deployed, a folder with the same name is created in the %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\FEATURES folder of every server in the farm.
  9. Modify the value of the Assembly element’s Location attribute, replacing “AssemblyName.dll” with the filename of your rule’s assembly.
  10. Save manifest.xml.
To create a directive file for the solution package
  1. Create a package folder in your Visual Studio project.
    In Solution Explorer, right-click the project name, choose Add, and choose select New Folder. Type Package.
    This is the output directory for the MAKECAB.EXE command-line utility.
  2. Create a Data Directive File (.ddf) in the Solution folder of your Visual Studio project.
    In Solution Explorer, right-click the folder named Solution, choose Add, and then choose New Item.... In the Add New Item dialog, select the Text Filetemplate. Name the file cab.ddf. Then click Add.
    This file will be used with the MAKECAB.EXE command-line utility.
  3. Open cab.ddf in the editor. Copy the following markup and paste it into the cab.ddf file.
    .OPTION EXPLICIT     ; Generate errors
    .Set CabinetNameTemplate=SolutionName.wsp
    .set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory.
    .Set CompressionType=MSZIP;** All files are compressed in cabinet files.
    .Set UniqueFiles="ON"
    .Set Cabinet=on
    .Set DiskDirectory1=Package ; This is the output directory.

    ; Files to include.
    Solution\manifest.xml manifest.xml
    Features\FeatureFolderName\feature.xml FeatureFolderName\feature.xml
    bin\Release\AssemblyName.dll AssemblyName.dll
  4. Modify the value of the CabinetNameTemplate argument, replacing “SolutionName” with the filename that you want to use for your solution package. (Keep the .wsp file extension.)
  5. Replace “FeatureFolderName” (it occurs twice) with the name of the folder in your solution that contains the file feature.xml.
  6. Replace “AssemblyName.dll” (it occurs twice) with the filename of your rule’s assembly. In addition, if the relative path to the assembly is not “bin\Release\”, replace that string with the correct path.
  7. Save cab.ddf.

To create the solution package file

  1. Open a Visual Studio command prompt.
  2. Navigate to the directory for your Visual Studio project.
    The file paths in cab.ddf and in the command that is issued in the next step are relative to the Visual Studio project directory.
  3. At the command prompt, issue the following command:
    makecab /f solution\cab.ddf
    A solution package is created in the Package folder.
Uploading and Deploying the Solution
After you create a new solution package, you should test it on a SharePoint installation. This involves two tasks: First, you must upload the solution package to the server farm. Second, you must deploy the solution.
Note: Your solution includes a Feature that is scoped at the server farm level. Because a farm-level Feature is automatically activated when it is installed, you do not need to issue a command to activate it manually.

To upload and deploy a solution package to the farm

  1. Open SharePoint Management Shell as an administrator by right-clicking the item on the Start/Administrative Tools menu and then selecting Run as administrator.
  2. At the command prompt, issue the following command to upload the solution. (Substitute the full path and filename for your solution package.)
    add-spsolution -literalpath

    The solution package is now uploaded to the server farm.
  3. At the command prompt, issue the following command to deploy the solution. (Substitute the correct filename for your .wsp file.)
    install-spsolution -identity filename.wsp -force -gacdeployment
The Solution is been deployed.

No comments:

Post a Comment

Sharepoint