At some point you will have to upgrade your event receiver, web part, ribbon etc. and in some cases you will have to upgrade files, or you will need to add some.
The section <UpgradeActions> will provide us the fastest way of doing it, At the end of the day we only need to edit the Feature.Xml file and add the section. If you double click in the feature a screen like this will pop up (see below), just click on “(Open in XML Editor)” and you will have a nice Feature.xml to play around.
If we add the <UpgradeActions> code that come in the MSDN documentation (http://msdn.microsoft.com/en-us/library/ee537575.aspx) we should have something like this:
1: <?xml version="1.0" encoding="utf-8" ?>2: <Feature xmlns="http://schemas.microsoft.com/sharepoint/">3: <UpgradeActions4: ReceiverAssembly="MyFeatureReceiver,5: Version=126.96.36.199,6: Culture=neutral,7: PublicKeyToken=2f2197d99d6e2871"8: ReceiverClass="FeatureReceiver.TestFeatureReceiver">9: <CustomUpgradeAction10: Name="DeleteField">11: <Parameters>12: <Parameter13: Name="FieldName">Address314: </Parameter>15: </Parameters>16: </CustomUpgradeAction>17: <VersionRange18: BeginVersion="188.8.131.52"19: EndVersion="184.108.40.206">20: <!-- Here you specify other upgrade actions to apply to Feature instances whose versions are within the range 220.127.116.11 to 18.104.22.168 -->21: </VersionRange>22: <MapFile FromPath=”oldname.gif” ToPath=”newname.gif” />23: </UpgradeActions>24: </Feature>
Have a look to line 22, what we are doing here it is renaming files, but you can also move them. If for example we have a folder called “images” in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\FEATURES\MyFeature\images\netsourcecode.gif we can call <MapFile> with the following path:
1: <MapFile FromPath=”images\netsourcecode.gif” ToPath=”Images\newnetsourcecode.gif” />
or just move it to another folder (%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\FEATURES\MyFeature\Gifs\) so we will have
1: <MapFile FromPath=”images\netsourcecode.gif” ToPath=”Gifs\newnetsourcecode.gif” />
Conclusion: As you can see, sometimes we try to find the answer in the code, but in this case this text file Feature.xml will bring us the fastest way to rename/move a file.