diff --git a/AutoT4/AutoT4.csproj b/AutoT4/AutoT4.csproj index 1fcf2d2..3419d0c 100644 --- a/AutoT4/AutoT4.csproj +++ b/AutoT4/AutoT4.csproj @@ -139,7 +139,12 @@ Always true + + + Menus.ctmenu + Designer + true diff --git a/AutoT4/AutoT4Package.cs b/AutoT4/AutoT4Package.cs index 2438de5..747f339 100644 --- a/AutoT4/AutoT4Package.cs +++ b/AutoT4/AutoT4Package.cs @@ -5,6 +5,8 @@ using EnvDTE; using System.Linq; using System.Collections.Generic; +using System.ComponentModel.Design; +using System; namespace BennorMcCarthy.AutoT4 { @@ -13,8 +15,12 @@ namespace BennorMcCarthy.AutoT4 [Guid(GuidList.guidAutoT4PkgString)] [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExists_string)] [ProvideOptionPage(typeof(Options), Options.CategoryName, Options.PageName, 1000, 1001, false)] + [ProvideMenuResource("Menus.ctmenu", 1)] public sealed class AutoT4Package : Package { + private const int CommandId = 0x0100; + private static readonly Guid CommandSet = new Guid("92c31ba2-5827-4779-b3ff-cf0fed43e50a"); + private DTE _dte; private BuildEvents _buildEvents; private ObjectExtenders _objectExtenders; @@ -38,6 +44,11 @@ protected override void Initialize() RegisterExtenderProvider(VSConstants.CATID.VBFileProperties_string); RegisterEvents(); + + var commandService = (IMenuCommandService)GetService(typeof(IMenuCommandService)); + var menuCommandID = new CommandID(CommandSet, CommandId); + var menuItem = new MenuCommand(this.RunTemplates, menuCommandID); + commandService.AddCommand(menuItem); } private void RegisterEvents() @@ -78,6 +89,14 @@ private void RunTemplates(vsBuildScope scope, RunOnBuild buildEvent, bool runIfD .ForEach(item => item.RunTemplate()); } + private void RunTemplates(object sender, EventArgs e) + { + _dte.GetProjectsWithinBuildScope(vsBuildScope.vsBuildScopeSolution) + .FindT4ProjectItems() + .ToList() + .ForEach(item => item.RunTemplate()); + } + protected override int QueryClose(out bool canClose) { int result = base.QueryClose(out canClose); diff --git a/AutoT4/AutoT4Package.vsct b/AutoT4/AutoT4Package.vsct new file mode 100644 index 0000000..87db13c --- /dev/null +++ b/AutoT4/AutoT4Package.vsct @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutoT4/Resources/GenerateT4.png b/AutoT4/Resources/GenerateT4.png new file mode 100644 index 0000000..e703341 Binary files /dev/null and b/AutoT4/Resources/GenerateT4.png differ