Tuesday, September 23, 2008

SharePoint: Deploying WebPart/Feature as SharePoint Solution Package (.wsp file) - Part 3

Link to Part 1 : Creating Skeleton.
Link to Part 2 : Creating Features/Webparts
Link to Part 3 : Creating .ddf and Manifest.xml (current post)
Link to Part 4 : Using STSADM and Centeral Admin to add and deploy solution

Once we have all our feature and webparts ready its not time to create Manifest.xml file and .ddf file.

<?xml version="1.0" encoding="utf-8" ?>
<Solution xmlns="http://schemas.microsoft.com/sharepoint/" SolutionId="{08A0C3C9-5586-4b1a-9598-B77DCAC64847}"

    <FeatureManifest Location="HandsOnFeature\feature.xml"/>
    <Assembly DeploymentTarget="WebApplication" Location="HandsOnWsp.dll">
        <SafeControl Assembly="HandsOnWsp, Version=, Culture=neutral, PublicKeyToken=35651a817c3c3a2e" Namespace="ClassLibrary1" Safe="True"  TypeName="*"/>

    <DwpFile FileName="handsOnWebpart.webpart" Location="HandsOnFeature/handsOnWebpart.webpart"/>

Manifest file defines the list of features, site definitions, resource files, Web Part files, and assemblies to process. It does not define the file structure—if files are included in a solution but not listed in the manifest XML file, they are not processed in any way. In addition, you can add a DwpFiles element to specify .webpart or .dwp files, or a ResourceFiles element to specify resource files, site definitions, application resources, and code access security policies.

DDF file
;*** Sample Source Code MakeCAB Directive file example
.OPTION EXPLICIT ; Generate errors
.set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory
.Set CompressionType=MSZIP;** All files are compressed in cabinet files
.Set UniqueFiles="OFF"
.Set Cabinet=on
.Set SourceDir=C:\Documents and Settings\rohillas\My Documents\Visual Studio 2008\Projects\HandsOn_Wsp\HandsOn_Wsp\ClassLibrary1\;

"Manifest.xml" Manifest.xml
"Features\HandsOnFeature\feature.xml"  HandsOnFeature\feature.xml
"Features\HandsOnFeature\element.xml" HandsOnFeature\element.xml
"Features\HandsOnFeature\me.aspx" HandsOnFeature\me.aspx
"Webparts\handsOnWebpart\handsOnWebpart.webpart" HandsOnFeature\handsOnWebpart.webpart
"Webparts\handsOnWebpart\handsOnWebpart.xml" HandsOnFeature\handsOnWebpart.xml
"bin\Debug\HandsOnWsp.dll" HandsOnWsp.dll

Note: For some reason relative part did not seem to work. Give it a shot !!

As you see, the manifest.xml file defines which files are parts of the solution that must be deployed on the front-end Web server. After you define the manifest.xml file, compile it into a CAB file with all the other required files. This is done by using the MAKECAB.EXE command-line utility. When you use this tool, you must define a .ddf file that instructs MAKECAB.EXE which files to include in the output CAB file.

The basic format of a DDF file is that of a text file. It contains one command per line. A line beginning with a single period is considered to be a command. Generally the first command is .OPTION EXPLICIT. For those of you familiar with Visual Basic, you'll recognize this sequence of words, which in this case means that if there's a problem processing the file MAKECAB should exit and report the error. The other commands that you'll use at the top of every DDF file that you're using to create a solution are:

1) .Set CabinetNameTemplate – Specifies the name of the output file—in this case, WFInspector.wsp

2) .Set DiskDirectoryTemplate=CDROM – Indicates that all of the CAB goes into a single directory

3) .Set CompressionType=MSZIP – Indicates that all of the files will be compressed into CAB files

4) .Set UniqueFiles="ON" – Indicates that all of the files referenced must be unique

5) .Set Cabinet=On – Use cabinet files

6) .Set DiskDirectory1=. – Use the current directory for the output CAB file 

In my next post I will discuss about building and deploying solution file.

No comments: