1 / 47

Code Camp NZ 2011

Code Camp NZ 2011. # CCNZ. www.mscommunities.co.nz. Deploying SharePoint Solutions and Features. Wayne Ewington Microsoft New Zealand. Who is Wayne Ewington?. Principal Consultant, Microsoft New Zealand SharePoint since Tahoe, NCompass Resolution 4.0  “ R5” July 2010

yves
Download Presentation

Code Camp NZ 2011

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Code Camp NZ 2011 #CCNZ www.mscommunities.co.nz

  2. Deploying SharePoint Solutions and Features Wayne Ewington Microsoft New Zealand

  3. Who is Wayne Ewington? • Principal Consultant, Microsoft New Zealand • SharePoint since Tahoe, NCompass Resolution 4.0  • “R5” July 2010 • wayne.ewington@microsoft.com • http://blogs.msdn.com/b/waynewin • When I get time (which isn’t that often)

  4. Agenda • Overview • Features and Lists • Feature Events • Feature Dependencies • Feature Stapling • Updating Solutions and Features

  5. What Are They? • Feature: “Collection of SharePoint elements” • Solution: “Deployable and reusable way to bundle components that extend SharePoint”

  6. So What! • Deployment should be a Design Goal .wsp .wsp Install Customisations Web Farm

  7. Installing and Deploying Solutions Web Farm Add Server Add Solution Deploy Solution .wsp SP Admin Central Admin .wsp .wsp Config DB

  8. Sandboxed SolutionsSolution catalog • New catalog available in the site collection level • _Catalogs/solutions • Contains the sandboxed solutions for particular site collection deployed by users

  9. Creating Solutions SP Project Items MakeCab.exe Manifest.xml .wsp CAB.ddf

  10. Manifest.xml manifest.xml Activation Dependencies ApplicationResourceFiles Assemblies CodeAccessSecurity DwpFiles FeatureManifests Resources RootFiles SiteDefinitionManifests TemplateFiles

  11. Manifest.xml <SolutionSolutionId="4AFC1350-F354-4439-B941-51377E845F2B" xmlns="http://schemas.microsoft.com/sharepoint/"> <FeatureManifests> <FeatureManifestLocation="CodeCamp\feature.xml"/> </FeatureManifests> <TemplateFiles> <TemplateFileLocation="1033\xml\webtempcodecamp.xml"/> </TemplateFiles> <Assemblies> <AssemblyDeploymentTarget="GlobalAssemblyCache" Location="CodeCampFeatureReceiver.dll"/> </Assemblies> </Solution>

  12. CAB.ddf .OPTION EXPLICIT .Set CabinetNameTemplate=CodeCamp.wsp ; All cabinets go in a single directory .set DiskDirectoryTemplate=CDROM ;** All files are compressed in cabinet files .Set CompressionType=MSZIP .Set UniqueFiles="ON" .Set Cabinet=on .Set DiskDirectory1=Package build \manifest.xml manifest.xml build \CodeCamp\feature.xml CodeCamp\feature.xml ...

  13. SharePoint Solutions demo

  14. Activating Features Web Farm Feature.xml Activate Feature Browser Content DB

  15. What can you do with Features? • Custom Actions • Controls • Workflows • Fields (Site Columns) • Content Types • List Templates • List Instances • Web Templates • Deploy Files

  16. Feature Scopes Farm Web Application Site Collection Sandbox Solutions Web Site

  17. Feature.xml <?xmlversion="1.0"encoding="utf-8"?> <FeatureId="00BFEA71-E717-4E80-AA17-D0C71B360101" Title="$Resources:core,documentlibraryFeatureTitle;" Description="$Resources:core,documentlibraryFeatureDesc;" Version="1.0.0.0" Scope="Web" Hidden="TRUE" DefaultResourceFile="core" xmlns="http://schemas.microsoft.com/sharepoint/"> <ElementManifests> <ElementManifestLocation="ListTemplates\DocumentLibrary.xml"/> </ElementManifests> </Feature>

  18. Creating a Simple Solution and Feature demo

  19. Features and Lists • Field Columns • Content Types • List Templates • List Instances

  20. Feature.xml <?xmlversion="1.0"encoding="utf-8" ?> <Feature Id="68C88F67-CF32-4474-8F42-9C89D8465395" Title="Code Camp List" Description="Code Camp List Feature" ... > <ElementManifests> <ElementManifestLocation="FieldTypes.xml"/> <ElementManifestLocation="ContentTypes.xml"/> <ElementManifestLocation="ListDefinitions.xml"/> <ElementManifestLocation="ListInstance.xml"/> </ElementManifests> </Feature>

  21. Field Types (Site Columns) <?xmlversion="1.0"encoding="utf-8" ?> <Elementsxmlns="http://schemas.microsoft.com/sharepoint/"> <Field ID="{714A856F-127A-40a3-9628-58906B51B048}" Name="FullName" DisplayName="Full Name" Group="Code Camp Columns" Type="Text" MaxLength="100" Hidden="False" Required="True" SourceID="http://schemas.microsoft.com/sharepoint/v3" /> </Elements>

  22. Content Types <?xmlversion="1.0"encoding="utf-8" ?> <Elementsxmlns="http://schemas.microsoft.com/sharepoint/"> <ContentType ID="0x01001ABBAD4652DE4CCEAB3C270F1DFD5F86" Name="Code Camp Content Type" Description="This is a Code Camp Content Type" Group="Code Camp"> <FieldRefs> <FieldRefID="{82642ec8-ef9b-478f-acf9-31f7d45fbc31}" Name="LinkTitle"DisplayName="Quote Text" Sealed="TRUE"Required="TRUE"/> <FieldRefID="{bc91a437-52e7-49e1-8c4e-4698904b2b6d}" Name="LinkTitleNoMenu"DisplayName="Quote Text" Sealed="TRUE"Required="TRUE"/> <FieldRefID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"Name="Title"DisplayName="Quote Text" Sealed="TRUE"Required="TRUE"/> <FieldRefID="{BABE2FC9-19C5-4310-8DE2-2C365770EE62}" Name="QuoteAuthor"DisplayName="Author Name" Required="TRUE"/> <FieldRefID="{F005C9BF-D147-428b-AAEA-9D343CBB39F0}" Name="DateUsed"DisplayName="Date Last Used" Format="DateOnly"/> </FieldRefs> </ContentType> </Elements>

  23. Content Types 0x01001ABBAD4652DE4CCEAB3C270F1DFD5F86 Separator GUID Base Type Provides an inheritance model

  24. Inheriting Content Types demo

  25. Content Types <?xmlversion="1.0"encoding="utf-8" ?> <Elementsxmlns="http://schemas.microsoft.com/sharepoint/"> <ContentType ID="0x01001ABBAD4652DE4CCEAB3C270F1DFD5F86" Name="Code Camp Content Type" Description="This is a Code Camp Content Type" Group="Code Camp"> <FieldRefs> <FieldRefID="{82642ec8-ef9b-478f-acf9-31f7d45fbc31}" Name="LinkTitle"DisplayName="Quote Text" Sealed="TRUE"Required="TRUE"/> <FieldRefID="{bc91a437-52e7-49e1-8c4e-4698904b2b6d}" Name="LinkTitleNoMenu"DisplayName="Quote Text" Sealed="TRUE"Required="TRUE"/> <FieldRefID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"Name="Title"DisplayName="Quote Text" Sealed="TRUE"Required="TRUE"/> <FieldRefID="{BABE2FC9-19C5-4310-8DE2-2C365770EE62}" Name="QuoteAuthor"DisplayName="Author Name" Required="TRUE"/> <FieldRefID="{F005C9BF-D147-428b-AAEA-9D343CBB39F0}" Name="DateUsed"DisplayName="Date Last Used" Format="DateOnly"/> </FieldRefs> </ContentType> </Elements>

  26. List Templates <?xmlversion="1.0"encoding="utf-8" ?> <ElementsId="5315E35D-BCA7-4a9f-A77D-EF62E01D437D" xmlns="http://schemas.microsoft.com/sharepoint/"> <ListTemplate FeatureId="68C88F67-CF32-4474-8F42-9C89D8465395" Name="TechEdList" DisplayName="TechEd List" Description="List for TechEd." Type="10001" BaseType="0" OnQuickLaunch="False" SecurityBits="11"/> </Elements>

  27. Schema.xml • List URL • Content Types • Fields • List Content Types • Views • Forms • View, Edit, and Create • Copy an existing Schema.xml and modify  • VS.NET 2010 is even easier!!! <?xmlversion="1.0"encoding="utf-8"?> <ListTitle="TechEd List"Url="Lists/TechEdList"BaseType="0"FolderCreation="FALSE"DisableAttachments="True"xlmns="http://schemas.microsoft.com/sharepoint/" > <MetaData> <ContentTypes> <ContentTypeRefID="0x01001ABBAD4652DE4CCEAB3C270F1DFD5F86"> <FolderTargetName="TechEd List" /> </ContentTypeRef> <ContentTypeRefID="0x0120" /> </ContentTypes> <Fields> <FieldID="{82642ec8-ef9b-478f-acf9-31f7d45fbc31}"Name="LinkTitle"DisplayName="Quote Text"Sealed="TRUE"Required="TRUE"/> <FieldID="{bc91a437-52e7-49e1-8c4e-4698904b2b6d}"Name="LinkTitleNoMenu"DisplayName="Quote Text"Sealed="TRUE"Required="TRUE"/> <FieldID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"Name="Title"DisplayName="Quote Text"Sealed="TRUE"Required="TRUE"/> <FieldID="{BABE2FC9-19C5-4310-8DE2-2C365770EE62}"Name="QuoteAuthor"DisplayName="Author Name"Type="Text"MaxLength="64"Hidden="False"Required="True" /> <FieldID="{F005C9BF-D147-428b-AAEA-9D343CBB39F0}"Name="DateUsed"DisplayName="Date Last Used"Type="DateTime"Hidden="False"Required="False" /> </Fields> <Views> <ViewBaseViewID="0"Type="HTML"Name="TechEd View"DisplayName="TechEd View"DefaultViewForContentType="True"List="TechEd/TechEdList"> ... </View> </Views> <Forms> <FormType="DisplayForm"Url="DispForm.aspx"SetupPath="pages\form.aspx"WebPartZoneID="Main" /> <FormType="EditForm"Url="EditForm.aspx"SetupPath="pages\form.aspx"WebPartZoneID="Main" /> <FormType="NewForm"Url="NewForm.aspx"SetupPath="pages\form.aspx"WebPartZoneID="Main" /> </Forms> </MetaData> </List>

  28. List Instance <?xmlversion="1.0"encoding="utf-8" ?> <Elementsxmlns="http://schemas.microsoft.com/sharepoint/"> <ListInstance Id="20007" FeatureId="68C88F67-CF32-4474-8F42-9C89D8465395" Title="TechEd Lookup List" Description="Lookup list used to say how great TechEd is" Url="Lists/TechEdLookup"> TemplateType="10001“ OnQuickLaunch="False" <Data> <Rows> <Row> <FieldName="Title">Fantastic</Field> </Row> <Row> <FieldName="Title">Brilliant</Field> </Row> </Rows> </Data> </ListInstance> </Elements> List Template Type

  29. List Feature demo

  30. Feature Events • Provides the ability to execute Code • Assembly must be deployed before the Feature is activated • “Clean up” on Feature Deactivation • Leave no residue! • Watch for Reactivation Bugs!!! • (You would be amazed)

  31. Event Receiver using System; usingMicrosoft.SharePoint; namespaceTechEd.SharePoint { publicclassTechEdFeatureReceiver : Microsoft.SharePoint.SPFeatureReceiver { publicoverridevoidFeatureActivated(SPFeatureReceiverProperties properties) { } publicoverridevoidFeatureDeactivating(SPFeatureReceiverProperties properties) { } publicoverridevoidFeatureInstalled(SPFeatureReceiverProperties properties) { } publicoverridevoidFeatureUninstalling(SPFeatureReceiverProperties properties) { } publicoverridevoidFeatureUpdating(SPFeatureReceiverPropertiesproperties) { } } }

  32. SPWebConfigModification // Create a Configuration Modification for the Compilation attribute SPWebConfigModificationconfigurationModification = newSPWebConfigModification(); configurationModification.Owner = properties.Feature.DefinitionId.ToString(); configurationModification.Sequence = 0; configurationModification.Path= "configuration/system.web/compilation"; configurationModification.Name = "debug"; configurationModification.Value = "true"; configurationModification.Type= SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute; currentWebApplication.WebConfigModifications.Add(configurationModification); // Save web.config changes currentWebApplication.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications(); // Commit the changes made currentWebApplication.Update();

  33. FeatureEvents and web.config demo

  34. Feature Dependencies Feature A Feature B Feature D Deactivate Activate Feature C

  35. Feature.xml <?xmlversion="1.0"encoding="utf-8" ?> <Feature Id="895DC494-CA68-413A-81D7-4A302EC3E355" Title="Code Camp Customisations" ... > <ActivationDependencies> <ActivationDependency FeatureId="F881EFC3-CA4C-42d3-9A06-DF31E82B6012"/> </ActivationDependencies> <ElementManifests> ... </ElementManifests> </Feature>

  36. Feature Stapling Site Template Create Site FeatureStaple FeatureStaplee

  37. Feature.xml <Elementsxmlns="http://schemas.microsoft.com/sharepoint/"> <FeatureSiteTemplateAssociation Id="541F5F57-C847-4e16-B59A-B31E90E6F9EA" TemplateName="STS#0"> </FeatureSiteTemplateAssociation> </Elements> Feature Site Definition

  38. Upgrading Solutions Upgrade Solution .wsp (v2) SP Admin .wsp (v2) .wsp (v1) Config DB

  39. Structuring Solutions WSP 1 “Core” Features WSP “Core” Features WSP 2 “Visual” Features “Visual” Features Workflow Features WSP 3 Workflow Features

  40. Solution Dependencies • Ensures a dependent solution is avalable and deployed • Does not deploy dependent solutions • Dependency check at deployment time • No VS 2010 Designer support

  41. Upgrading Features • AddContentTypeField • Adds an existing field to a Content Type • Option to push to List Content Types • MapFile • Changes unghosted file paths in the database • ApplyElementManifest • Adds elements as part of the upgrade • CustomUpgradeAction • Specify Receiver Class – Defaults to Feature Assembly • Optional Parameters

  42. Upgrading Features Feature Element files Element files Feature v1 Element files Element files Feature v2 XML Feature Receiver To modify existing sites To modify creation of new sites Upgrade Action

  43. When are Features Upgraded? • Sandbox • Solution must have a different name! • Farm Wide • psconfig.exe -cmd upgrade -inplace b2b • Object Model • Feature.Upgrade()

  44. Upgrading Solutions demo

  45. In Conclusion • Solutions and Features are COOL  • Deployment should be a Design Goal • Upgrading should be a Design Goal .wsp .wsp Customisations Install Web Farm

  46. Thanks to our sponsorsand partners! Sponsor Premier Partners Associated Partners Supporting Partners

More Related