Creating Advanced Solutions for SharePoint 2007, Page 2
TemplateFiles, Resources, and ApplicationResourceFiles Element
The TemplateFiles, Resources, and ApplicationResourceFiles elements are very similar to the RootFiles element; they create a copy of one or more templates, resources, or resource files for the complete application in the chosen directory:
<TemplateFiles> <TemplateFile Location="Text"/> ... </TemplateFiles> <Resources> <Resource Location="Text"/> ... </Resources> <ApplicationResourceFiles> <ApplicationResourceFile Location="Text"/> ... </ApplicationResourceFiles>
Resource files need to be installed in a feature directory. In the following example, the resource file "JupiterMedia.es-co.resx" will be copied to the "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\FeatureName" directory:
<Resources> <Resource Location="FeatureName\JupiterMedia.es-co.resx "/> </Resources>
Application Resource Files are general resources that SharePoint will use for different purposes, for example, localization files that can be installed in the "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Resources" directory.
Features are a new concept introduced in SharePoint 2007, and offer services to install, activate, deactivate, and uninstall functionality. There are some notable differences between Solutions and Features: the former were created to install complete packets of functionality, covering the entire SharePoint system; Features can install only one element at a time. However, within that limitation, Features modify the user interface of SharePoint (add menu's, for example) in an uncomplicated way.
Features can be installed using Solutions (the opposite is not possible). The syntax is:
<FeatureManifests> <FeatureManifest Location="Text"/> </FeatureManifests>
<FeatureManifests> <FeatureManifest Location="JupiterMediaFeature\feature.xml"/> </FeatureManifests>
Install the "JupiterMediaFeature" feature in the features directory "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\FEATURES". Observe that Features will be installed, but not activated, by the Solution.
To install SharePoint Site Definitions, the following syntax is applied:
<SiteDefinitionManifests> <SiteDefinitionManifest Location="Text"> <WebTempFile Location="Text"> </SiteDefinitionManifest> ... </SiteDefinitionManifests>
Each Site Definition needs to be linked to a location in the Template structure of SharePoint. The subsequent example copies the Site Definition "webtempSTS.xml" to the "STS" Template:
<SiteDefinitionManifests> <SiteDefinitionManifest Location='STS'/> <WebTempFile Location='1033\STS\webtempSTS.xml'/> </SiteDefinitionManifest> </SiteDefinitionManifests>
Assemblies and ClassResources Elements
Installing assemblies is also possible using a Solution. The assembly can be installed in the GAC or in the local Bin directory, together with its registration in the web.config file by means of the following:
<Assemblies> <Assembly DeploymentTarget = "GlobalAssemblyCache" | "WebApplication" Location = "Text"> <SafeControls> ... </SafeControls> </Assembly> </Assemblies>
The "DeploymentTarget" parameter determines whether the assembly reaches the GAC or goes to the Bin directory; the "SafeControls" element ensures its registration in the Safe Controls section of the web.config (this element is not obligatory):
<Assemblies> <Assembly DeploymentTarget="GlobalAssemblyCache" Location="JupiterMediaAssembly.dll"> <SafeControls> <SafeControl Assembly="JupiterMediaAssembly, Version=188.8.131.52, Culture=neutral, PublicKeyToken=f435cbfb3fb57aec" Namespace="JupiterMediaAssembly" TypeName="*" Safe="True" /> </SafeControls> </Assembly> </Assemblies>
The "ClassResources" element identifies the resources class for an assembly. The syntax permits defining the file name and location, in the same way as previously explained for other elements:
<ClassResources> <ClassResource FileName = "Text" Location = "Text"> </ClassResource> ... </ClassResources>