Have you ever been writing code like this:

SPContext.Current.Site.Features.Add(new Guid("7F304722-681E-4237-87A0-1989FBA5EBDC"));

but would much rather write something like this:


and were too lazy to maintain the Guids both in feature.xml and in code? Then this project might be your solution.


This T4 template will search your project for feature.xml-files, validate them, and generate code with the feature guids.



Generated sourcecode:
using System;   
using System.Runtime.CompilerServices;

namespace My.SharePoint.Solution.Features
  public static class Feature1
    public static readonly Guid Id = new Guid("430a4d5b-443c-433f-87e9-502d92d98f29");
  public static class Feature2
    public static readonly Guid Id = new Guid("233be6dd-4214-4284-bc6f-23492cf76aa2");


Download and include it in your visual studio project (Tested with VS 2008 and SharePoint 2007).

Last edited Nov 15, 2009 at 4:42 PM by ahvam, version 7