Is FeatureUpgrading supposed to use the latest Property values?
The 1.0.0.0 version of my Feature's Template.xml file looked like this:
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/">
<Properties>
<Property Key="AvailableWebTemplates" Value="MPS#0;MPS#1;MPS#2;MPS#3;MPS#4" />
</Properties>
</Feature>
The new version 1.1.0.0 is as follows:
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/">
<UpgradeActions>
<VersionRange BeginVersion="1.0.0.0" EndVersion="1.1.0.0">
<CustomUpgradeAction Name="UpgradeTo1v1"/>
</VersionRange>
</UpgradeActions>
<Properties>
<Property Key="AvailableWebTemplates" Value="MPS#0;MPS#1;MPS#2;MPS#3;MPS#4;STS#2" />
</Properties>
</Feature>
The value of templates
is still MPS#0;MPS#1;MPS#2;MPS#3;MPS#4
, when the following code runs in FeatureUpgrading:
SPFeatureProperty property = properties.Feature.Properties["AvailableWebTe开发者_C百科mplates"];
string templates = property.Value;
Why am I not getting the updated property value? Is this the way it is supposed to be?
This is indeed the way it is supposed to be: A feature has 1 definition and n instances. The code in FeatureUpgrading is used to upgrade the instances.
The property in your xml updates the feature definition and not the running instances.
properties.Feature.Properties["MyProp"]
gets the property value of the running instance properties.Definition.Properties["MyProp"]
gets the value of the property in the feature definition.
精彩评论