Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add icon to existing menu command in Visual Studio 2017

Disclaimer: this is about using Visual Studio and its GUI. It is not about a VS extension.

Context:

I like to have toolbar buttons to sort and remove using directives in .cs files. In VS 2015 there were two dedicated commands (and hence buttons) to do this, each with their own icon. Now in VS 2017 there's a single command to do that (Remove and Sort Usings) but it has no icon, just text. See pciture below, command is there, but text only:

enter image description here

I remember ages ago, with VS 2010 I believe, you could somehow hack VS existing commands so to show custom icons. I think it was a matter of adding picture files in a special location, and either name them in a special way or reference them from some configuration file. I totally forgot how, but it was doable.

Question:

Does anyone know if this is still possible with VS 2017 and how? After some search I was not able to find an answer.

BTW question is similar to this unanswered one, but in my case it's about a regular VS command, not an external tool command.

TA

Edit: as suggested in comments, this CommandingImage extension used to work on VS 2010. It has not been updated, nor open-sourced, nor ported. Maybe someone as found its successor.

like image 867
superjos Avatar asked Jan 05 '18 19:01

superjos


People also ask

How do I add a menu bar in Visual Studio?

Add, remove, or move a toolbarOn the menu bar, choose Tools > Customize. The Customize dialog box opens. On the Toolbar tab, perform one of the following sets of steps: To add a toolbar, choose the New button, specify a name for the toolbar that you want to add, and then choose the OK button.

How do I add the menu bar in Visual Studio code?

Go to VSCode settings ( CTRL+, or CMD+, ) and search for shortcut menu bar . Toggle buttons from there.


1 Answers

With Visual Studio 2017, it can be done using Visual Studio SDK where you can either write a extension or extend a existing menu command with a icon declared in the .vsct file. A simple example for the your need can be found here.

If you want to go for a simpler way, I would suggest to either use PowerCommands or Resharper to do the same. See here.

like image 101
Robionic Avatar answered Oct 19 '22 11:10

Robionic