How to get the sharepoint feature version from feature.xml file programmatically?

StackOverflow https://stackoverflow.com/questions/7043036

  •  17-12-2020
  •  | 
  •  

Domanda

I have got the the next task recently: increment the version of the sharepoint feature each time when we are building the project. I have completed it successfully using the attribute "Version" in feature.xml file. I change it executing the custom code within MSBuild. So, the feature version in xml file changes, but how can I get it programmatically when the feature is working? I use SharePoint Server 2007, Visual studio 2008. I'll appreciate any help. Thank you. P.S. SPFarm.Local.BuildVersion contains another version, which is different from the version in feature.xml file.

È stato utile?

Soluzione

Try this:

var spFarm = GetYourSPFarmObject();

System.Version version = spFarm.FeatureDefinitions["YourFeatureNameHere"].Version;

Also, if you're inside the feature event receiver and are trying to get its version, you can do:

System.Version version = properties.Definition.Version;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top