Hi,
I am just experimenting with Feature upgrade in 2010
Scenario That I am trying to implement:-
Add a custom list definition that adds custom "sales" list to the Site and deploy the feature. Later extend the feature (by incermenting version and including UpgradeActions) to add another new list def (i.e, add Customer list) . And now when this feature is upgarded, I should see the new list (Customer) on the site without deactivating and activating existing feature.
Behaviour I observed:-
I see that when feature is upgraded. The feature.xml file in 14 hive gets replaced by updated feature.xml file, aslo I can see the new customer\elements.xml file in the 14 hive. But when I browse the site I cannnot see the "Customer" list provisioned. But, when I decativate and activate the existing feature, then I can see the "Customer" list. But, what I was expecting was, I should see the new customer list provioned without re-activating the feature. Because I think thats the purpose of feature upgrade in 2010.
Below is my feature.xml code:-
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"Version="2.0.0.0" Title="FeatureupgardeTest" Id="36f3ce15-9af6-4eaf-9469-0a3d66ae5d86><ElementManifests><ElementManifest Location="SalesListUpgradev1\Elements.xml"/><ElementManifest Location="CustomerListV2\Elements.xml"/></ElementManifests><UpgradeActions><VersionRange EndVersion="2.0.0.0"> <ApplyElementManifests><ElementManifest Location="CustomerListV2\Elements.xml"/></ApplyElementManifests></VersionRange></UpgradeActions></Feature>
PowerShell Upgrade script:-
param([string]$siteUrl, [string]$solutionName, [string]$featureId) Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue" function WaitForUpgrading($solutionName) { $farm = [Microsoft.SharePoint.Administration.SPFarm]::Local $isExecuted = $true $solution = $null foreach ($farmSolution in $farm.Solutions) { if ($farmSolution.Name.Equals($solutionName, [System.StringComparison]::InvariantCultureIgnoreCase)) { $solution = $farmSolution break; } } if ($solution -ne $null) { while ($solution.JobExists) { write-host ***Waiting "while" $solutionName is being upgraded...*** [System.Threading.Thread]::Sleep(5000) } $result = $solution.LastOperationResult if ($result -ne [Microsoft.SharePoint.Administration.SPSolutionOperationResult]::DeploymentSucceeded -and $result -ne [Microsoft.SharePoint.Administration.SPSolutionOperationResult]::DeploymentWarningsOccurred) { write-host "EXCEPTION:" $solutionName has been upgraded with ERRORS } else { write-host $solutionName has been successfully upgraded! } } } function UpgradeFeatures($featureId) { write-host Start upgrading features at $siteUrl $featureGuid = New-Object System.Guid($featureId) $features = $site.QueryFeatures($featureGuid, $true) foreach($feature in $features){ $feature.Upgrade($false) write-host " " write-host ---- $feature.Definition.DisplayName was upgraded. Parent: $feature.Parent---- } write-host " " write-host Finish upgrading } $site = Get-SPSite $siteUrl write-host " " WaitForUpgrading $solutionName UpgradeFeatures $featureId
Why is that I can see the new "Customer" list def in 14 hive. But the list itself is not showing up in the Site unless I re-activate the feature?
Also, I tried including "<CustomUpgradeAction>" element in feature.xml file and implemented "FeatureUpgrading" event reciver but still I see the same behaviour.
I dont think it is required to implement "<CustomUpgradeAction>" and "FeatureUpgrading" event bcz all of the list creation info is specified in Elements.xml file.
Thanks in advance,