Question

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.

Was it helpful?

Solution

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top