Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Reading the Feature.xml or Elements.xml file that has been installed to sharepoint

What I want is to be able to see what has been installed to sharePoint, not what is on the hard drive in the Features folder. For example I had some properties in my Feature.xml file like this:

<Properties>
  <Property Key="LibraryName" Value="Custom Images" />
</Properties>

After installing and activating the feature I noticed some properties were missing, so I added the properties to the Feature.xml file.

At this point what is installed to SharePoint is different to what is on the hard drive. I know I have to remove and re-add the feature, but I need some way of reading what has been installed for troubleshooting purposes.

share|improve this question
add comment

3 Answers

SharePoint Feature Administration and Clean Up Tool is an excellent tool to help you accomplish your goal. Of course you can:

Find faulty FeatureDefinitions and cleanly uninstall them.

Find Feature remainders in Sites, SiteCollections, WebApps and in the Farm, from e.g. forcefully uninstalled Features from farm without deactivating them before, causing errors. Also, de-/activate Features Farm wide.

share|improve this answer
add comment

By using feature receiver you can get path to feature folder with property SPFeatureReceiverProperties.Definition.RootDirectory and when get any file from this folder.

msdn:

SPFeatureReceiverProperties.Definition Property

SPFeatureDefinition.RootDirectory Property

share|improve this answer
    
I take it this can only be done when activating a feature? Ideally I wanted some kind of stsadm command or a database query to get the information. –  PeterM Sep 16 '11 at 9:19
    
@PeterM, FeatureActivated will be executed after your new Feature.xml will be copied to 14 hive. So, this approach will work only if you place the code in some other feature, and activate it first. –  Andrey Markeev Sep 16 '11 at 9:45
    
Ok, I wrote a quick client program in VB on my image. This gives me feature.xml. Now I need the elements.xml Dim Feature As SPFeature Dim xml As System.Xml.XmlNode Using sitecollection As SPSite = New SPSite("WSS3") Using Site As SPWeb = sitecollection.OpenWeb() Feature = Site.Features(New Guid("00BFEA71-52D4-45B3-B544-B1C71B620109")) xml = Feature.Definition.GetXmlDefinition(New System.Globalization.CultureInfo("en-gb")) MessageBox.Show(xml.OuterXml) End Using End Using –  PeterM Sep 16 '11 at 9:59
add comment

I suppose you're looking for the SharePoint feature upgrade framework. It will allow you to use feature versioning and perform some custom upgrade actions. However, this is not an easy thing, so you'll need to investigate it intently.

Chris O'Brien SharePoint MVP has article series about this:

share|improve this answer
    
I had been wondering how to uppgrade a feature, this looks very useful and worth further investigation. –  PeterM Sep 16 '11 at 10:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.