'How to execute custom file specific command / task in Visual Studio?

I would like to be able to define custom commands/task/macro for a VisualStudio solution. Then I would like to execute that command for a file that is selected in the Solution Explorer.

There are several possibilities to execute the command that would be fine for me:

a) Right click on the file in the Solution Explorer and choose the command from the context menu (my favorite)

b) Select a file in the Solution Explorer. Then click on a button on a tool bar. The command would then somehow retrieve the selected file from the Solution Explorer.

c) Select a file in the Solution Explorer. Then start a task from the Task Runner Explorer. The executed task would somehow retrive the selected file from the 'Solution Explorer'

I tried to use the VisualStudio extension VsCommandBuddy. However, it does not support file specific commands, see

https://github.com/PaulHuizer/VsCommandBuddy/issues/21

I also tried to use a Grunt or Gulp task that can be started from the Task Runner Explorer. However, I don't know how I can pass/access the file that is currently selected in the Solution Explorer.

https://blogs.msdn.microsoft.com/webdev/2016/01/06/task-runners-in-visual-studio-2015/

=> Is there a VisualStudio extension that easily allows to define custom commands for files?

=> How can I pass/access the file that is selected in the SolutionExplorer in script files (e.g. Gulp, Grunt, Webpack)?

=> Any other comfortable work flow that you would recommend?

It would be possible to write my own VisualStudio extension. But I guess that someone else already knows a solution for this.



Solution 1:[1]

You can use my Visual Commander extension to define a custom command/macro. On how to get the currently selected file in Solution Explorer see In a VS 2015 extension, how can I get the selected object in the Solution Explorer?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sergey Vlasov