September 30, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Creating Advanced Solutions for SharePoint 2007

  • May 3, 2007
  • By Gustavo Velez
  • Send Email »
  • More Articles »

Introduction: Building Solutions, Hands-On

My previous article Creating Solutions for SharePoint 2007 discussed the importance of SharePoint 2007 Solutions for developers in the shadow of the difficulties deployment of the customizations posed for SharePoint 2003. The article introduced the three methods of utilizing Solutions: employing the "stsadm" administration tool of SharePoint, using the Central Administration Web interface, or proceeding programmatically.

The .cab deployment solution for WebParts in SharePoint 2003 was the basis for the design of SharePoint 2007 Solutions. A SharePoint Solution consists of all the files needed for the components to be deployed plus a manifest (xml) file that describes the modus operandi of the files. The Solution file is a cabinet-based .cab file with a ".wsp" extension in place of the ".cab" extension.

By way of a Solution, it is possible to install most types of customizable components of SharePoint such as Site definitions, Features, WebParts, Templates and assemblies. Additionally, the Code Access Security (CAS) policies can be modified in the web.config.

Solution Schema and Walking Through the Creation of Solutions

The .wsp file can have an internal tree structure, and the Solution manifest file (obligatory to have the name "manifest.xml") must be located in the root of the structure. The manifest file gives instructions to the Solution engine in SharePoint regarding the modus operandi of the other files in the Solution; however, it does not define the structure of the components. Subsequently, a file may exist in the .wsp Solution file, but if the file is not mentioned in the manifest, it will always be disregarded.

The general schema of the manifest file is:

<Solution
 DeploymentServerType = (Optional) "ApplicationServer" | "WebFrontEnd"
 ResetWebServer = (Optional) "TRUE" | "FALSE"
 SolutionId = (Optional) "Text or GUID"
 xmlns="http://schemas.microsoft.com/sharepoint/">
   <Elements...
      ApplicationResourceFiles
         ApplicationResourceFile
      Assemblies
         Assembly
            SafeControls
               SafeControl
            ClassResources
               ClassResource
      CodeAccessSecurity
         PolicyItem
            PermissionSet
               IPermission
            Assemblies
               Assembly
      DwpFiles
         DwpFile
      FeatureManifests
         FeatureManifest
      Resources
         Resource
      RootFiles
         RootFile
      SiteDefinitionManifests
         SiteDefinitionManifest
            WebTempFile
      TemplateFiles
         TemplateFile
   ...>
</Solution>

The parameters of the "Solution" section define the scope of deployment; the Solution initiates "iisreset" after activation ("ResetWebServer" Parameter), as well as the ID (a string or GUID) and the NameSpace. Inside the Solution tag, the Elements of the Solution can be defined. The following illustrates a Solution with different elements, beginning with the Solution metadata:

<Solution SolutionId = "12345678-90AB-CDEF-1234-567890ABCDEF"
 xmlns="http://schemas.microsoft.com/sharepoint/">

 . . .

</Solution>

The GUID can be created with the Visual Studio generator or constructed manually.

RootFiles Element

The "RootFiles" element copies the defined files in a particular directory:

<RootFiles>
   <RootFile
      Location = "Text">
   </RootFile>
   ...
</RootFiles>

The "Location" parameter identifies the final localization of the file. The localization in the structure of the .wsp file needs to mirror the final localization in the server, and is relative to the 12 hive where the SharePoint files are localized. Thus, the tags

<RootFiles>
   <RootFile
      Location = "TEMPLATE\IMAGES\MyPic.jpg">
   </RootFile>
</RootFiles>

will copy the file "MyPic.jpg", found in the directory "TEMPLATE\IMAGES" in the .wsp file, to the directory "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES" of SharePoint.

If the file cannot be found in the correct place in the .wsp file, the installation of the Solution will be aborted.





Page 1 of 4



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel