External tools command or .vsix extension (Folder View mode) receive multiple selected file paths?

Ed Dude 1 Reputation point

I need to launch a tool of mine that takes two file paths as args, which I have multi-selected in Solution Explorer.

Both files are not open in edit windows and are usually in different projects as well. The only thing they have in common is being in the solution somewhere.

Question 1 - External Tools

$(ItemPath) et al only deal with a single current window, are there any variables for passing along what is currently (multi-)selected in the Solution Explorer view, or am I stuck having to make a .vsix to do that?

Example repro 1.1

  • create a solution with two ClassLibrary projects on .NET Core 3.1 (doesn't really matter, just make any two projects)
  • multi-select two files from the two different projects in the Solution Explorer window (the Class1.cs files do nicely)
  • do not open any editor windows (just to avoid any red herrings by having windows open and taking part in associating as ItemPath, etc)
  • open Tools->External Tools and Add a new one (I used WinMerge, use anything you want here)
  • populate the Arguments for the added tool with ... ??? (it isn't ItemPath which is for the current editor windows in focus; it would be some var or expr representing the file paths of the two items selected in the Solution Explorer window)


Example repro 1.2

  • same as previous Example repro 1.1, but Switch to Available Views and do it with Solution Explorer in Folder View instead
    (because tools that only need the file paths my selections are pointing at should be able to get them from Folder View as well; there is nothing "project-y" about the file paths to files)


Question 2 - .vsix that works on multiple files selected in Solution Explorer (and in Folder View mode)

When I try a .vsix I can't make it work when Solution Explorer is simply doing folder nav in Folder View. I suspect that is because the project item model of a normal .sln isn't the same when it is merely viewing folders and files - odd considering any extension that just works on the level of passing a file path or two should also operate when you are merely using VS as a fancy file explorer.

Is there a .vsix example that shows how to build an extension that can respond properly to multiple files selected in either the regular Solution Explorer project view mode, as well as the Folder View mode?

Example repro 2.1

  • create a .vsix extension project which does the following:
  • add a context menu option to invoke a tool ( again, doesn't matter what - could just be echo)
  • the context menu option should appear when right-clicking on files in either Solution Explorer view mode (both Project and Folder view)
  • the context menu option should appear and operate on either multi-selected file, and the file(s) selected are all available within the menu option callback processing
    (in both 1.1 and 1.2 Example repros above, invoking the context menu over either of the two selected files will give both files as info to use inside the callback)
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,433 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 26,481 Reputation points Microsoft Vendor

    Hi @Ed Dude ,

    For your requirement, it isn’t currently supported. In Visual Studio Marketplace, I try to search extensions and can’t find such extensions to meet your requirement. I suggest you report it to Developer Community.

    Thanks for your understanding.


    • If the answer is helpful, please click "Accept Answer" and upvote it.
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    0 comments No comments