Can I add an options menu to my VSIX extension without adding a VSPackage?

I have a very lightweight Visual Studio extension. It's currently just a MouseProcessor and a KeyboardProcessor in one class file, a vsixmanifest, and the necessary two icons.

I want to add a simple menu for it in the Tools > Options. Just a boolean to toggle on/off.

It's my first extension, and it was quite a learning curve to get this far. Every tutorial I find assumes that I'm using a VSPackage, and in fact, MSDN doesn't make it clear that you can have an extension without one. Obviously this isn't the case, though.

Using a VSPackage, or at least, creating a new VSPackage project, seems like it adds a whole lot of weight to the project. I'm wondering if there's a very light way to add a simple Options menu to my extension, either without a VSPackage or with a very small VSPackage load.

The code in question is on GitHub at https://github.com/norachuga/MiddleClickToPeekDefinition . It lets you middle-click on a word to Peek Definition, or ctrl+middleclick to Go To Definition. I want to add a boolean menu option to flip those, so middle-click is Go To Definition and ctrl+middleclick is Peek Definition.

Answers


The lightest possible VSPackage is demonstrated in commit f3e23a3 here. In particular, you need the following:

  1. A class derived from Package, similar to OutputWindowPackage. Keep the PackageRegistration attribute, but you can omit ProvideBindingPath if your extension only has one assembly. You can simplify the dependencies by referencing the VSSDK.Shell.12 NuGet package (for an extension only targeting Visual Studio 2013 and newer).

  2. Update the source.extension.vsixmanifest to include the <VsPackage>|%CurrentProject%|</VsPackage> line.

  3. Update the project file to set <GeneratePkgDefFile>true</GeneratePkgDefFile> and <CopyBuildOutputToOutputDirectory>true</CopyBuildOutputToOutputDirectory>.

  4. Make sure the project file has <IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer> (it should even before you update the project).


Need Your Help

Custom key for a HashMap

java dictionary hashmap

I need to map a [Integer, List&lt;Integer&gt;] key to an Integer. I have considered the following approaches and am struggling to figure which is most beneficial, given that speed is key.

How to extract stack size of all library functions from c code?

linux gcc assembly dll stack

I have few benchmarks like fft, dijkstra. I want to collect the stack size of all library functions and user defined functions. C code is also available.