A community driven effort for a better Visual Studio experience developing extensions.
The NuGet package Community.VisualStudio.Toolkit.17 acts as a companion to the regular Visual Studio SDK packages with helper methods, classes and extension methods that makes writing extensions a lot easier.
- The VSIX Cookbook shows you how to build extensions using this toolkit
- Community.VisualStudio.Toolkit.17 official NuGet package
- CI NuGet feed for nightly builds
- Visual Studio 2015 (Community.VisualStudio.Toolkit.14)
- Visual Studio 2017 (Community.VisualStudio.Toolkit.15)
- Visual Studio 2019 (Community.VisualStudio.Toolkit.16)
- Visual Studio 2022 (Community.VisualStudio.Toolkit.17)
Create a file called nuget.config in your solution folder, and paste in the following content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="Toolkit CI" value="https://ci.appveyor.com/nuget/community-visualstudio-toolkit" />
</packageSources>
</configuration>
Here are some examples of typical scenarios used in extensions.
You can now write commands much simpler than you're used to. Here's what a command that opens a tool window would look like:
[Command(PackageIds.RunnerWindow)]
internal sealed class RunnerWindowCommand : BaseCommand<RunnerWindowCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) =>
await RunnerWindow.ShowAsync();
}
await VS.StatusBar.ShowMessageAsync("My status bar text");
await VS.MessageBox.ShowAsync("Title", "Message");
Synchronous version:
catch (Exception ex)
{
ex.Log();
}
Async version:
catch (Exception ex)
{
await ex.LogAsync();
}
To incorporate a DI container into your extension, see the complimentary project: Community.VisualStudio.Toolkit.DependencyInjection
This package attempts to solve multiple issues with the current extensibility model.
Base classes, helper methods, and extension methods encapsulate the complexity so you don't have to.
Now the most common services are all easy to get to from the main VS
object.
The underlying implementation of the project uses the best practices for each version of VS it supports. This ensures that your extension is much more likely to handle threading correctly, and avoid hangs and crashes.
The most common APIs of the old complex COM nature are wrapped to expose a modern async API. This makes it much easier to code against the API and you can avoid the EnvDTE
object for most scenarios.
All the base classes and helper methods are async by default. There are cases where they are not, but that is because it wouldn't be beneficial for them to be.
This is a living project where the whole community can contribute helpers on top of the official VS SDK. There is no need to wait for Microsoft to make an update, since this project gives the ability to continue the work in a separate work stream.
This project works around those changes in the implementation of its public contracts and interfaces. This means that what was a breaking change to the VS SDK, becomes an implementation detail of this project and no user will be affected.
For both project- and item templates that utilizes this NuGet packages, download the Extensibility Template Pack:
- Extensibility Template Pack 2022 (Visual Studio 2022)
- Extensibility Template Pack 2019 (Visual Studio 2019)