Visual Studio 2015 Extensibility at Build 2016

Why to write an extension? It would be cool if it would be something that would improve my workflow. If I could fix a bug in Visual Studio and get around an issue that I found in Visual Studio. Do you want to write a private extension or do you want to share your extension with the rest of the world? Visual Studio is a canvas of endless possibilities.

What do you want to write? Collect your own ideas or go to User Voice and check the feature requests for Visual Studio.

100 new extensions going live every month in the Visual Studio Gallery. It’s a great place to be and a lot of cool things coming out all the time. You can write your own or contribute to an extension if it is open source.

What makes an extension cool?

Ext1

Install Extensibility Tools 2015, makes it easy for us to write extensions.

Create a new project, under C# select Extensibility. Select the VSIX project template. Getting started page with links to the tools and samples. Open the VSIX manifest to add metadata to the extension, this is just an XML file. Add new item: Custom Command. This installs everything needed from Nuget and adds references.

In CommandPackage.vsct we put the UI together: Group is container for buttons but does nothing. Define parent for group, in which menu it should appear. Define parent for button to be the group. We have to register everything: groups and buttons. You get full IntelliSense. In CommandPackage.cs implement the MenuItemCallback. Any command can be invoked, you can find them in CommandWindow e.g. Tools.DiffFiles.

When we run the project, it opens an experimental instance of Visual Studio.

Super crisp icons and screenshots, well written descriptions are important. Icons are PNGs, you can do JPEG but don’t. Over 3000 icons shipped with Visual Studio. Go to Tools, Export Image Moniker, it gives you all the images that are inside Visual Studio and you can also search here.This registers the icon in GuidSymbol and use it in Bitmaps. There are two: icon and preview image. Go to the manifest and fill out Icon and Preview Image.

Put the extension on GitHub. We want to have contribution guidelines, README file, changelog, license, template for issues. Right click on the solution, Extensibility Tools, Prepare this for GitHub. Add existing items, add the license file as a link, go to Properties set to Content and it goes inside the VSIX. Make sure that people know what the extension does, by providing clear high quality screenshots. Paste the screenshot straight into the editor and in the README file. Now we can commit to GitHub, add solution to source control, commit and push to GitHub. GitHub extension for Visual Studio helps you get started with GitHub.

When we make a change we want to automatically push it. Right click on the solution, Extensibility Tools, Prepare for AppVeyor. This adds file, commit. Go to AppVeyor, it’s for free, and add new build. This talks to GitHub, it automatically starts a new build with each new commit. Anybody can check nightly builds in VSIX Gallery. Upload to Visual Studio Gallery, fill out the information, provide link to source control, save and publish.

Creating an issue on GitHub uses the template. It is added to the roadmap. When fixing the issue, increase version and extend the changelog. Commit the changes with issue number in the comments and GitHub automatically closes the issue. Upload the new version to Visual Studio Gallery.

One of the great things in Visual Studio 2015 for both extension authors and users are the automatic updates by default. Extension authors have more downloads. Really good for the users: no more notifications to the users and users get the fixes faster.

Let’s be really geeky. 🙂 In order for people to help out, we want to make it as simple as possible. We want to make the code and project structure simple.

Help, About shows the installed extensions. VSPackage.resx contains resources for title and description and icons. We want to automate this. In the manifest auto-sync resx and icon file and this automatically generates the resx file and icons. VSIX class generated with version, author and so on which can be used in the code to avoid repeating this information. This is all about making it super easy for people what’s going on to increase the participation from the community.

Keep the extension small. Right click Solution Image Optimizer to compress the images.

Advertisements