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.
In the Solution Explorer, right-click the project node and select Add > New Item. In the Add New Item dialog, go to Visual C# > Extensibility and select Command. In the Name field at the bottom of the window, change the command file name to FirstCommand.
Command
$(SolutionDir)
, $(ItemPath)
(=file path), ... to customize your external commandTools=>Customize=>Commands
Select Context menu: Project and Solution Context Menu | Item
Add Command...=>Tools=>External Command 1
Use the new context menu entry for items in the solution explorer
In order to cancel/stop an external command, you can also use the context menu of the solution explorer. If the original name of the command is "Test with Karma", the title will be modified to "(Stop) Test with Karma" as long as the command is running. =>Select that entry to stop the command.
Unfortunately those settings can not be stored with the Solution (?). It is however possible to export those settings. Then a colleague can import them:
Tools=> Import and export Settings...=>Next
General Settings=> External Tools List and
General Settings=> Menu and Command Bar Customizations
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With