Your SlideShare is downloading. ×
0
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Deep dive into feature versioning and upgrade support in SharePoint 2010
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Deep dive into feature versioning and upgrade support in SharePoint 2010

1,801

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,801
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • In 2007 provisioning artefacts and then upgrading them was like head butting a brick wall. It’s quick and easy to create these things in the Web UI in one environment, and extremely easy to add new Site Columns to existing Content Types. Or modify Web Part properties.But when you have 10 Site Collections with 20 Content Types and have to modify them in Development, Test and Production. This is tedious for every promotion of a change. This is why we do development over configuration.
  • Some things are easier than others to replace.Definitions vs InstancesMost are not aware that although you define a Content Type at the Site Collection level, if you create a List in a sub site and attach a Content Type to the List it creates an Instance which has a “link” back to the definition. The same is true of List Templates, although this works slightly different again in that once a List Instance is created, if you modify the List Template the changes are promoted to the List Instance. This is by design, you would need to imperatively update each List Instance. This is why it is encouraged to use Content Types because at least you can push down changes to Fields that way.Pushing Changes DownIn the UI you can change the definition and it pushes the changes down to these instances, but if you do it imperatively in code you have to be careful. It is unsupported to change Content Type Definitions declaratively.Module PagesModule Pages in a Site Collection will reference the file deployed in the Feature within the SharePoint Root (hive), and as long as they are not customised, will automatically take the updated version.
  • Module PagesModule Pages in a Site Collection will reference the file deployed in the Feature within the SharePoint Root (hive), and as long as they are not customised, will automatically take the updated version.
  • Deactivate/ActivateThis is a common approach where you just deactivate the feature and reactive which will run the Feature Receiver code where you could imperatively “do stuff” like check columns existed on Content Types etc. to ensure that they matched the Definition in the Content Type manifest in the Feature.In most instances it will pull out the Content Type defintions etc. if they are not used and then on Activation it will provision the new updated Definition. This does not work if the Content Type is in use, which in most cases it will be.Clean upSome people will actually remove Definitions on Deactivation to clean up. Such as Content Type Definitions or even List Templates and Web Parts. Remember that when you deactivate, by default it will leave any instances deployed by Module elements e.g. Web Part Definitions and Master Pages.PowerShellIn 2007 some people used PowerShell to imperatively go through instances in each Site Collection and tweak them. Sometimes, as a Developer it was often slower to sit and work out the API to modify a Content Type compared to a few seconds in the UI. There’s snippets of code all over the web for this and we’ll have the same issues again in SharePoint 2010 although a lot of the SharePoint 2007 stuff is re usable.Don’t overuse features where you are for instance just creating a Images Library on100 sites and deploy a Solution Package with a Feature with List Instance in it. Simply recurse through the sites with PowerShell to provision it.
  • Feature Version actually means something in SharePoint 2010. It was unused attribute in SharePoint 2007.
  • #create new project#create content type based on Article#run package solutionAdd-SPSolution -LiteralPath "C:\\Users\\sp_admin\\Documents\\Visual Studio 2010\\Projects\\SharePointProject4\\SPDevWiki.ContentTypesFarmDemo\\bin\\debug\\SPDevWiki.ContentTypesFarmDemo.wsp"Install-SPSolution -Identity "SPDevWiki.ContentTypesFarmDemo.wsp" -GACDeployment#show that farm feature has it at 1.0.0.0get-spfeature | where {$_.DisplayName -eq 'SPDevWiki.ContentTypesFarmDemo_SPDevWiki.ContentTypesFarmDemo' } | select DisplayName, Version#show that feature doesn't exist at Site Collection yet$site = get-spsite "http://sp2010rtm:99"$feature = $site.Features | where {$_.DefinitionId -eq 'cc9f1e0b-44ac-4a75-880c-768576cfd4eb' }$featureEnable-SPFeature -Identity "SPDevWiki.ContentTypesFarmDemo_SPDevWiki.ContentTypesFarmDemo" -Url "http://sp2010rtm:99"#show that feature does exist at Site Collection$site = get-spsite "http://sp2010rtm:99"$feature = $site.Features | where {$_.DefinitionId -eq 'cc9f1e0b-44ac-4a75-880c-768576cfd4eb' }$feature#Add UpgradeActions for new Site column on Content Type#add a ApplyElementManifests#add the xml snippet#create the new Manifest File - highlight that field isn't a new SPI#Increment Feature Version from 1.0.0.0 to 2.0.0.0Update-SPSolution -Identity "SPDevWiki.ContentTypesFarmDemo.wsp" -LiteralPath "C:\\Users\\sp_admin\\Documents\\Visual Studio 2010\\Projects\\SharePointProject4\\SPDevWiki.ContentTypesFarmDemo\\bin\\debug\\SPDevWiki.ContentTypesFarmDemo.wsp" -GACDeployment#Show how feature is updated in Farm - show it doesn't show up updated versionget-spfeature | where {$_.DisplayName -eq 'SPDevWiki.ContentTypesFarmDemo_SPDevWiki.ContentTypesFarmDemo' } | select DisplayName, Version#Need to shut down PowerShell to reflect the change here!get-spfeature | where {$_.DisplayName -eq 'SPDevWiki.ContentTypesFarmDemo_SPDevWiki.ContentTypesFarmDemo' } | select DisplayName, Version#Show how Version isn't updated on site yet$site = get-spsite "http://sp2010rtm:99"$feature = $site.Features | where {$_.DefinitionId -eq 'cc9f1e0b-44ac-4a75-880c-768576cfd4eb' }$feature#Run the upgrade$feature.Upgrade($false);#show that feature has upgraded on Site Collection now$feature#show Content Type updated showing new field#now show feature installed on new Site Collection that hasn't had it enabled beforeEnable-SPFeature -Identity "SPDevWiki.ContentTypesFarmDemo_SPDevWiki.ContentTypesFarmDemo" -Url "http://sp2010rtm:81"#show ContentType re-appears and that feature is now on 2.0.0.0$site = get-spsite "http://sp2010rtm:81"$feature = $site.Features | where {$_.DefinitionId -eq 'cc9f1e0b-44ac-4a75-880c-768576cfd4eb' }$feature#show that content Type does not have the new field#Run the upgrade$feature.Upgrade($false);#Show that content Type still does not have the new field$feature#Raise importance that you still need to add the stuff to the base content type too#Upgrade is purely to incrementally upgrade instances!#add <FieldRef /> to contenttypeUpdate-SPSolution -Identity "SPDevWiki.ContentTypesFarmDemo.wsp" -LiteralPath "C:\\Users\\sp_admin\\Documents\\Visual Studio 2010\\Projects\\SharePointProject4\\SPDevWiki.ContentTypesFarmDemo\\bin\\debug\\SPDevWiki.ContentTypesFarmDemo.wsp" -GACDeployment#Show that feature now has the new field#now add a feature receiver and add the code snippets#copy the feature assembly info into the upgrade feature assembly bits in properties window#add <CustomUpgradeAction Name="Upgrade6.0.0.0To7.0.0.0" /> to new VersionRangeUpdate-SPSolution -Identity "SPDevWiki.ContentTypesFarmDemo.wsp" -LiteralPath "C:\\Users\\sp_admin\\Documents\\Visual Studio 2010\\Projects\\SharePointProject4\\SPDevWiki.ContentTypesFarmDemo\\bin\\debug\\SPDevWiki.ContentTypesFarmDemo.wsp" -GACDeployment#close powershell#run$site = get-spsite "http://sp2010rtm:99"$feature = $site.Features | where {$_.DefinitionId -eq 'cc9f1e0b-44ac-4a75-880c-768576cfd4eb' }$feature#note that if this fails, stays at existing feature version but antying it's managed to do declaritively and imperatively will be done and not rolled out (ARGHHH!)$feature.Upgrade($false);$feature#not used#remove featureDisable-SPFeature -Identity "SPDevWiki.ContentTypesFarmDemo_SPDevWiki.ContentTypesFarmDemo" -Url "http://sp2010rtm:99"#show it gone from Content Types list#now remove v2.0.0.0 in fullUninstall-SPSolution -Identity "SPDevWiki.ContentTypesFarmDemo.wsp"Remove-SPSolution -Identity "SPDevWiki.ContentTypesFarmDemo.wsp"#now add v3.0.0.0 solutionAdd-SPSolution -LiteralPath "C:\\Users\\sp_admin\\Documents\\Visual Studio 2010\\Projects\\SharePointProject4\\SPDevWiki.ContentTypesFarmDemo\\bin\\debug\\SPDevWiki.ContentTypesFarmDemo.wsp"Install-SPSolution -Identity "SPDevWiki.ContentTypesFarmDemo.wsp" -GACDeploymentEnable-SPFeature -Identity "SPDevWiki.ContentTypesFarmDemo_SPDevWiki.ContentTypesFarmDemo" -Url "http://sp2010rtm:99"
  • http://technet.microsoft.com/en-us/library/ee906565.aspxNote: You should probably start a new instance of PowerShell after each time you build, otherwise the actions you perform may be run against an outdated version of your assembly from the GAC.  The same thing sometimes applies to Visual Studio deployment, for instance if one solution refers to an assembly in another solution!
  • (get-spweb http://sp2010rtm:99/).Features | where {$_.DefinitionId -eq '7cd284c9-b998-457b-b782-4473744b7daf' }get-spfeature | where {$_.DefinitionId -eq '7cd284c9-b998-457b-b782-4473744b7daf' } | select DisplayName, Version
  • http://msdn.microsoft.com/en-us/library/ee538968(office.14).aspx
  • http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsite.queryfeatures(office.14).aspxReturns SPFeatureQueryResultCollection Depending on at what level you query the returned features could cover various scopesSPWebServiceFinds all instances of the feature with given id that require upgrade in the farm. All scopes of features (Farm, Web Application, Site collection, Web) are supported.SPWebApplicationFinds all instances of the feature with given id in all content databases. Web app/site collection/web scoped features are supported.SPContentDatabaseOverloads of QueryFeatures function of this class find site and web scoped features in content database that conform to filtering criteria. Returned collection is ordered with regard to web hierarchy. Parent web features goes before child web features and traversal of the tree is done in depth-first manner.SPSiteOverloads of QueryFeatures function of this class find web scoped features in site collection that conform to filtering criteria. Returned collection is ordered with regard to web hierarchy. Parent web features goes before child web features and traversal of the tree is done in depth-first manner. Overloads of QueryFeatures function of this class will be available in Client OM.
  • Transcript

    • 1. Deep dive into feature versioning and upgrade support in SharePoint 2010<br />Jeremy Thake<br />
    • 2. Jeremy Thake <br />Enterprise Architect since April ’11 at AvePoint<br />SharePoint MVP since July ’10<br />Co-Founder of NothingButSharePoint.com<br />Speaker at MS TechEd 2009/10, SPC 11<br /> Gplus.to/jthake<br /> @jthake<br />
    • 3. AGENDA<br /><ul><li>Introduction
    • 4. Declarative
    • 5. Imperative
    • 6. What to watch
    • 7. How to prepare 2007 Solution Packages</li></li></ul><li>
    • 8. &lt;Field&gt;<br />&lt;ContentType&gt;<br />&lt;ListInstance&gt;<br />&lt;WebPart&gt;<br />&lt;WorkflowInstance&gt;<br />
    • 9. Some easier than others<br />Definition vs. Instance<br />Site Column &lt;Field&gt;<br />SPSite, SPWeb<br />Content Type &lt;ContentType&gt; <br />SPSite, SPWeb, SPList<br />Web Part &lt;WebPart&gt; <br />WP Gallery, Instances on pages<br />List Template<br />SPSite, SPWeb, Instances at SPWeb<br />
    • 10. Some easier than others<br />Module (Page Layout, Master Page, Style sheets)<br />As long as not ‘customised’<br />Renaming files<br />
    • 11. “OLD SKOOL”<br />Imperative in-place upgrade<br />Deactivate/Activate -&gt; “if column missing add it”<br />Deactivate/Retract/Remove/Add/Deploy/Activate<br />Won’t work if in USE!<br />Field<br />Content Types – blocks delete<br />Web Parts out of gallery and Web Part Instances<br />List Templates – removes but breaks List instances<br />Workflow – removes assembly, breaks Workflow instances<br />New Feature - Stapling<br />PowerShell<br />
    • 12. V1.0.0.0<br />V12.0.0.0<br />
    • 13. One farm many feature versions active<br />SITE A<br />SITE B<br />SITE C<br />SPDevWiki<br />V1.0.0.0<br />SPDevWiki<br />V3.0.0.0<br />SPDevWiki<br />V2.0.0.0<br />SPDevWiki<br />V3.0.0.0<br />SPDevWiki<br />V3.0.0.0<br />SPDevWiki<br />V1.0.0.0<br />SPDevWiki<br />V2.0.0.0<br />SPDevWiki<br />V3.0.0.0<br />
    • 14.
    • 15. Upgrading features declaratively<br />Version attribute not just for show ;-)<br />Not set by default in XML so uses 0.0.0.0<br />ActivationDependencies can specify version<br />UpgradeActions element<br />VersionRange with Begin &amp; End versions<br />MinimumVersion<br />ApplyElementManifest<br />AddContentTypeField<br />MapFile<br />
    • 16. Upgrading Features Declaratively<br />DEMO<br />
    • 17. AddContentTypeField<br />Add Columns to ContentType<br />
    • 18. ApplyElementManifests<br />Integrated new artefacts into existing feature<br />E.g. New Fields in a Content Type<br />
    • 19. Mapfile<br />Repoint a file to a new location on filesystem<br />E.g. renaming/relocating a deployed style sheet<br />Uncustomised files only<br />
    • 20. DECLARATIVE FEATURE UPGRADE<br />
    • 21. Upgrading Feature Instances<br />DEMO<br />
    • 22. Code ran<br />update-spsolution -identity SharePointProject.wsp-literalpathbinDebugSharePointProject.wsp –GACDeployment<br />
    • 23. Powershell<br />get-spfeature | where {$_.DefinitionId -eq &apos;7cd284c9-b998-457b-b782-4473744b7daf&apos; }<br />| select DisplayName, Version<br />(get-spweb http://sp2010rtm:99/).Features | where {$_.DefinitionId -eq &apos;7cd284c9-b998-457b-b782-4473744b7daf&apos; }<br />psconfig -cmd upgrade -inplaceb2b<br />$site = get-spsite http://siteurl<br />$enabledfeature = $site.Features | where {$_.DefinitionId -eq &apos;7cd284c9-b998-457b-b782-4473744b7daf&apos; }<br />if($enabledfeature)<br />{<br /> $enabledfeature.Upgrade($false)<br />}<br />
    • 24. UPGRADEactions Imperative<br />Provide assembly &amp; class in UpgradeActions<br />CustomUpgradeActionss element provides Name and Parameters<br />Fires FeatureUpgrading event receiver<br />
    • 25. Upgrading Features Imperatively<br />DEMO<br />
    • 26. IMPERATIVE FEATURE UPGRADE<br />
    • 27. FEATUREUPGRADING EVENT RECEIVER<br />
    • 28. TIPS<br />Don’t forget to change definition as well do upgrade<br />ALWAYS quit PowerShell when rebuilding WSP<br />Or use different names for WSP<br />If CustomUpgradeAction fails, doesn’t upgrade feature<br />Will leave things “half baked” – defensive coding<br />Adjust ULS logs to see messages<br />‘Feature Infrastructure’, ‘Fields’, ‘General’<br />
    • 29. What to watch - Definitions<br />Copy definition, create new one, hide old version<br />List Templates<br />Workflow<br />Site Definitions<br />or Feature stapling<br />
    • 30. What to watch - instances<br />Web Parts<br />Imperatively modify properties<br />Assembly upgrade<br />List Instances<br />Incrementally upgrade<br />Workflows<br />Assembly upgrade on existing activities<br />Changing what activities exist on current instances<br />“You’re on your own soldier”<br />
    • 31. SANDBOXED SOLUTIONS<br />Slightly different!<br />Upgrade button for Sandboxed Solutions<br />On upgrading a Solution<br />All Features are upgraded automatically!<br />
    • 32. Solution version<br />Defined by having new wsp name <br />e.g. SPDevWiki_v1.0.0.0.wsp and SPDevWiki_v2.0.0.0.wsp<br />Sandboxed Solutions<br />Deploying different versions to different Site Collections in Farm<br />Supported in Farm Solutions<br />Easy way to identify what version in different Farms <br />no other way of identifying solutions<br />only keeps most recent<br />
    • 33. Assembly versions<br />New Assembly Version<br />Workflow instances + Web Part instances<br />Will remove old version from GAC breaking old Web Parts<br />Use Binding Redirect if not worried about old assembly version – if so why do it in the first place?<br />Assembly Versioning broken in Sandboxed Solutions<br />
    • 34. Feature upgrade object model<br />QueryFeatures method (4 overloads)<br />GuidfeatureId<br />GuidfeatureId, boolneedsUpgrade<br />GuidfeatureId, Version featureVersion<br />SPFeatureScope scope, boolneedsUpgrade<br />Available from SPWebService(Farm), SPWebApplication, SPContentDatabase &amp; SPSite<br />
    • 35. Versioning strategies<br />Main Goal<br />Identify which versions are across farm<br />Assembly version and Feature versions will diverge<br />Release notes needed!<br />Stick with one approach<br />Major.Minor.Build.Revision<br />Change severity (breaking/major/minor)<br />Shipping/non-shipping (product orientated)<br />Incorporate sprint/iteration<br />Incorporate changeset number<br />Other crazy approaches!<br />
    • 36. How can I prepare 2007 code?<br />Start versioning your features – default 0.0.0.0<br />&lt;SharePoint:UIVersionedContentUIVersion=“4”&gt;<br />Deprecated API’s<br />Binding redirects<br />VSeWSS -&gt; VS2010 supported<br />WSPBuilder/STSDev/STSADM/custom -&gt; manual<br />
    • 37. Sharepoint HEROES<br /><ul><li>Mike Morton (Microsoft)
    • 38. Chris O’Brien (SharePoint MVP)
    • 39. Josh Carlisle (SharePoint Brain Freeze)</li></li></ul><li>UI Feature upgrade<br />http://spfeatureupgrade.codeplex.com/<br />
    • 40. Visual Studio 2010 add-in <br />TechNet walkthrough for building VSIX add-in<br />http://msdn.microsoft.com/en-us/library/ee256698.aspx<br />Tommy Segoro (WA, AUS)<br />Completed code sample<br />http://vs2010spupgrade.codeplex.com/<br />
    • 41. REFERENCES<br />Recorded webinar and scripts from session<br />wss.made4the.net<br />My Delicious Links<br /><ul><li>SharePoint.Microsoft.com
    • 42. SharePoint 2010 Developer Resources
    • 43. Upgrading Custom Solutions</li></ul>SharePoint Patterns &amp; Practices Group (SPG)<br /><ul><li>SharePointDevWiki.com
    • 44. Getting Started in SharePoint 2010 development
    • 45. Building a SharePoint 2010 Dev Machine</li></ul>SPDevWiki Web Cast<br /><ul><li>Running SharePoint 2010 DevEnv</li></li></ul><li>Q &amp; A<br />

    ×