16

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.

superjos
  • 12,189
  • 6
  • 89
  • 134
  • 1
    VS2008 was the last version that support this out of the box, the feature was lost in the WPF rewrite at VS2010. Lots of complaints about it, so a team member wrote [an extension](https://blogs.msdn.microsoft.com/visualstudio/2010/06/17/command-image-changing-extension/) to get the feature back. Bad links in the blog post, I think it is [this one](https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.CommandingImage). But not very popular and not maintained, back to square one. I see other ones in the gallery, can't judge their quality. – Hans Passant May 06 '18 at 00:53
  • Oh, after visiting the blog post I remember also having used that one to set icons! – superjos May 06 '18 at 01:05
  • 2
    Be sure to note it in your question, you'll want an answer from somebody that used it as well and figured out which alternative works well in VS2017. – Hans Passant May 06 '18 at 01:13

1 Answers1

7

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.

Robionic
  • 315
  • 4
  • 14
  • There are like 3-5 productivity tools (easy-finds) that can accomplish this task. Those mentioned above and https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProductivityPowerPack2017, and there are more. I'd go with that one too. – Razvan Dumitru May 08 '18 at 14:26
  • I do have Power Commands extension but that does not fulfil what I'm looking for. I'm not sure I'm on the same track: it is not a matter of showing the Remove/Sort Using command in toolbar. That is doable already. I'm looking for a way to associate an icon to that command. I think I'll add a picture. The https://learn.microsoft.com/en-us/visualstudio/extensibility/adding-icons-to-menu-commands link about custom extensions can go in the right (although long) direction. – superjos May 08 '18 at 15:58
  • @Robionic do you know how to create such an extension, that only customizes appearance for an existing menu command? Would you like to expand your answer on that? Thanks – superjos May 10 '18 at 14:01