Over the past week, I’ve been working on an extension for Visual Studio called EpicBuildMusic. If you’ve watched my live stream on Twitch or Mixer, or caught the video afterwards on my YouTube channel, you’ve seen some of the challenges that I have run into. In this post, I’m going to summarize some of those learnings.
Configure Visual Studio with the SDK
To write an extension for versions of Visual Studio prior to 2017, you needed to download and install a separate software development kit (SDK) that supported your efforts. With the 2017 edition, the SDK is included in the standard installer and you simply need to opt in to it:
If you want to contribute to the EpicBuildMusic extension, you MUST have these tools installed.
It’s All About the Package
The center-piece of the the extension is a class that inherits from Package. The Package class can be compared to the Program class in a console application, as this is where your extension will be started and operates from.
In EpicBuildMusic, the Initialize method of the BuildMusicPackage class registers itself to listen for SolutionEvents that Visual Studio will raise. This is how the extension is notified of a build starting and ending. Those events are “UpdateSolution_Begin” and “UpdateSolution_Done”
Options, how to configure those options…
On Tuesday the 5th, I walked through how to create an options dialog on stream. I used this walkthrough from the MSDN site and learned a bit along the way. The custom page that I was creating inherits from a Dialog class and the user-interface could be easily swapped out with a Windows Forms UserControl. I know how to build usercontrols, so I started leaning on that experience to layout controls. The values for the fields were written back to the Dialog class, where Visual Studio automatically persists the values. It was nice to know that I didn’t have to write any complex database or file reading code to persist these settings.
It does appear that there is a scaling issue with the user-interface in Visual Studio 2017 with high-dpi displays, as my controls are resizing unexpectedly. I am probably missing something in my control class definition, and will follow up on that later.
Manifest and Packaging
Importantly, and I haven’t shown this on stream, the Manifest file for the extension shows the minimum Visual Studio requirements to install and run it. I have some basic information in the manifest now, including the version and description information for the project.
The basic modem sounds that I am deploying as the default ‘during build music’ needed to be bundled in the resultant VSIX file so that users would have it available on their machines. Simple enough, I have included that mp3 in file project and marked it as content, to be included in the VSIX:
Summary
I’m still learning about building Visual Studio extensions. This has been a productive exercise for me, and I think I’ll wrap up this series of streams about building the EpicBuildMusic extension on Saturday the 9th. Join me on Twitch or Mixer as I finish this first pass through the project.