Find features installed by a sharepoint solution
Can i find the list of the features which were installed 开发者_StackOverflow中文版by a shareopoint solution?
Unzip the wsp. From the unzipped folder you should be able to get all the features that are deployed using this wsp.
If you are referring to lsiting the features of an installed solution I think this will do the trick. You can add an if block to filter it down to a specific solution name/id if you wish.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Deployment;
using NUnit.Framework;
namespace Tests
{
[TestFixture]
public class EnumerationTests
{
[Test]
public void EnumeratingSiteFeatures()
{
using (var site = new SPSite("http://localhost:50000"))
{
var features = site.WebApplication.Farm.FeatureDefinitions;
var solutions = site.WebApplication.Farm.Solutions;
foreach (SPFeatureDefinition feature in features)
{
var solution = solutions[feature.SolutionId];
var featureName = feature.DisplayName;
Console.WriteLine(string.Format("Solution:{1}\nFeature:{0}\n", featureName, solution != null ? solution.DisplayName ?? solution.Name : "Solution was null"));
}
}
}
}
}
精彩评论