Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6163007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:45:13+00:00 2026-05-23T21:45:13+00:00

Is there a way to ‘Run Custom Tool’ for an entire solution? Why? The

  • 0

Is there a way to ‘Run Custom Tool’ for an entire solution?

Why? The custom tool is under development and when changes are made I need to refresh all the items that use it to make sure nothing breaks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:45:14+00:00Added an answer on May 23, 2026 at 9:45 pm

    Since I needed an answer for this and had to make it myself, here is the solution for “Run Custom Tool”.

    If you just need to run all your T4 templates again, then since VS2012 there is Transform all T4 in the Build menu.

    For VS2017 they have removed macros, so follow https://msdn.microsoft.com/en-us/library/cc138589.aspx and make a plugin with your menu item instead. E.g. Name your command RefreshAllResxFiles, and paste this file in (The default command set doesnt include the dlls for VSLangProj, so just find the appropiate package in NuGet):

    internal sealed class RefreshAllResxFiles
    {
      public const int CommandId = 0x0100;
      public static readonly Guid CommandSet = new Guid(copy the guid from guidRefreshAllResxFilesPackageCmdSet from the vsct file);
      private readonly Package _package;
      private readonly DTE2 _dte;
    
      /// <summary>
      /// Initializes a new instance of the <see cref="RefreshAllResxFiles"/> class.
      /// Adds our command handlers for menu (commands must exist in the command table file)
      /// </summary>
      /// <param name="package">Owner package, not null.</param>
      private RefreshAllResxFiles(Package package)
      {
         _package = package ?? throw new ArgumentNullException(nameof(package));
    
         var commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
         if (commandService != null)
         {
            var menuCommandId = new CommandID(CommandSet, CommandId);
            var menuItem = new MenuCommand(MenuItemCallback, menuCommandId);
            commandService.AddCommand(menuItem);
         }
         _dte = ServiceProvider.GetService(typeof(DTE)) as DTE2;
      }
    
      public static RefreshAllResxFiles Instance { get; private set; }
      private IServiceProvider ServiceProvider => _package;
    
      public static void Initialize(Package package)
      {
         Instance = new RefreshAllResxFiles(package);
      }
    
      /// <summary>
      /// This function is the callback used to execute the command when the menu item is clicked.
      /// See the constructor to see how the menu item is associated with this function using
      /// OleMenuCommandService service and MenuCommand class.
      /// </summary>
      private void MenuItemCallback(object sender, EventArgs e)
      {
         foreach (Project project in _dte.Solution.Projects)
            IterateProjectFiles(project.ProjectItems);
      }
    
      private void IterateProjectFiles(ProjectItems projectProjectItems)
      {
         foreach (ProjectItem file in projectProjectItems)
         {
            var o = file.Object as VSProjectItem;
            if (o != null)
               ProcessFile(o);
            if (file.SubProject?.ProjectItems != null)
               IterateProjectFiles(file.SubProject.ProjectItems);
            if (file.ProjectItems != null)
               IterateProjectFiles(file.ProjectItems);
         }
    
      }
    
      private void ProcessFile(VSProjectItem file)
      {
         if (file.ProjectItem.Name.EndsWith(".resx"))
         {
            file.RunCustomTool();
            Log(file.ProjectItem.Name);
         }
      }
      public const string VsWindowKindOutput = "{34E76E81-EE4A-11D0-AE2E-00A0C90FFFC3}";
    
      private void Log(string fileName)
      {
         var output = _dte.Windows.Item(VsWindowKindOutput);
         var pane = ((OutputWindow)output.Object).OutputWindowPanes.Item("Debug");
         pane.Activate();
         pane.OutputString(fileName);
         pane.OutputString(Environment.NewLine);
      }
    }
    

    And the old solution for macro:

    Option Strict Off
    Option Explicit Off
    Imports System
    Imports EnvDTE
    Imports EnvDTE80
    Imports EnvDTE90
    Imports VSLangProj
    Imports System.Diagnostics
    
    Public Module RecordingModule
        Sub IterateFiles()
            Dim solution As Solution = DTE.Solution
            For Each prj As Project In solution.Projects
                IterateProjectFiles(prj.ProjectItems)
            Next
        End Sub
    
        Private Sub IterateProjectFiles(ByVal prjItms As ProjectItems)
            For Each file As ProjectItem In prjItms
                If file.Object IsNot Nothing AndAlso TypeOf file.Object Is VSProjectItem Then
                    AddHeaderToItem(file.Object)
                End If
                If file.SubProject IsNot Nothing AndAlso file.SubProject.ProjectItems IsNot Nothing AndAlso file.SubProject.ProjectItems.Count > 0 Then
                    IterateProjectFiles(file.SubProject.ProjectItems)
                End If
                If file.ProjectItems IsNot Nothing AndAlso file.ProjectItems.Count > 0 Then
                    IterateProjectFiles(file.ProjectItems)
                End If
            Next
        End Sub
    
        Private Sub AddHeaderToItem(ByVal file As VSProjectItem)
            If file.ProjectItem.Name.EndsWith(".resx") Then
                file.RunCustomTool()
                Log(file.ProjectItem.Name)
            End If
        End Sub
        Private Sub Write(ByVal name As String, ByVal message As String)
            Dim output As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
            Dim window As OutputWindow = output.Object
            Dim pane As OutputWindowPane = window.OutputWindowPanes.Item(name)
            pane.Activate()
            pane.OutputString(message)
            pane.OutputString(Environment.NewLine)
        End Sub
        Private Sub Log(ByVal message As String, ByVal ParamArray args() As Object)
            Write("Debug", String.Format(message, args))
        End Sub
    
        Private Sub Log(ByVal message As String)
            Write("Debug", message)
        End Sub
    
    End Module
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there way of generating a string made up of 250 underscores, without using
Is there way to run self host a WCF service with ServiceHost on local
Is there way to clean up pending changes with Add value in column Change
Is there way to issue one command line to build a solution with all
Is there way to make custom signal when ManyToMany relations created?
Is there way in next piece of code to only get the first record?
is there way thats i can preselect an item when the page loads or
is there way how to get name ov event from Lambda expression like with
Is there way to better identify design pattern in source codes, esp. if you
Is there way to mute an audio stream or at least control the volume?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.