How can I write an extension to replace the icon for a built-in Visual Studio command (eg: Edit → Copy)?
Similarly how can I add an icon for a built-in command that doesn't have one (eg: File → Close)?
An answer to Add icon to existing menu command in Visual Studio 2017 indicates using an extension is the way to go, but I can't figure out how to implement it.
I've used the standard C# VSIX Project template and added a new custom Command.
To this I've added...
<!-- A toolbar -->
<Menus>
<Menu guid="guidVSIXProject1PackageCmdSet" id="ToolbarID" type="Toolbar">
<CommandFlag>DefaultDocked</CommandFlag>
<Strings>
<ButtonText>Test bar</ButtonText>
<CommandName>TestBar</CommandName>
</Strings>
</Menu>
</Menus>
<!-- A toolbar group -->
<Groups>
<Group guid="guidVSIXProject1PackageCmdSet" id="MyMenuGroup" priority="0x0600">
<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
</Group>
<Group guid="guidVSIXProject1PackageCmdSet" id="ToolbarGroupID" priority="0x0000">
<Parent guid="guidVSIXProject1PackageCmdSet" id="ToolbarID" />
</Group>
</Groups>
...
<!-- A button -->
<Button guid="guidVSStd97" id="cmdidCopy" priority="0x0300" type="Button">
<Parent guid="guidVSIXProject1PackageCmdSet" id="ToolbarGroupID" />
<Icon guid="guidImages" id="bmpPic2" />
<Strings>
<ButtonText>TestCopy</ButtonText>
</Strings>
</Button>
...
<!-- This doesn't seem to do anything -->
<UsedCommands>
<UsedCommand guid="guidVSStd97" id="cmdidCopy"/>
</UsedCommands>
I got cmdidCopy
from VsDbgCmdPlace.VSCT under <Visual Studio SDK installation path>
as documented in
GUIDs and IDs of Visual Studio commands. It appears on the toolbar & works, but with the original icon.
Weirdly, in the toolbar Customize dialog the new icon appears but not the new text!
Reason for question: VS icons are limited to miserly 16px and the stock icons are often hard for me to distinguish.
Edit: Still an issue in VS 2022 (v17.1.0). VSIX Community Toolkit discussion