Distribute Visual Studio Templates With Extensions Installer
In the article, we talk about how you can distribute the project/item templates you created among your peers.
Join the DZone community and get the full member experience.
Join For FreeHistory
While working on the Bellatrix project, we wanted to find ways to solve all 40+ problems in the best possible way. There were a couple of things that we had to address — distribute the getting-started projects (the so-called starter-kits) across all platforms and give people a fast way to create new Bellatrix test projects.
So, we used three different solutions for test project creation — Visual Studio project templates, .NET Core templates, and custom-made cross-platform templates. One of the ways for deploying the Bellatrix item and project templates was through Visual Studio extensions installers. Here I am going to share with you how you can use them too.
Create VSIX Project Template
Prerequisites
To find the VSIX project template, you must install the Visual Studio SDK.
1. Click Tools > Get Tools and Features...
2. From the Visual Studio Installer, install Visual Studio extension development
Create VSIX Project
1. Open New Project wizard
2. Create new empty VSIX project
3. Create a desired item or project templates
For more information on how to speed up tests writing, check the last four articles in the series:
Standardize Page Objects with Visual Studio Item Templates
Create Multiple Files Page Objects with Visual Studio Item Templates
Speed up Automated Tests Writing with Visual Studio Project Templates
Speed up Automated Tests Writing with .NET Core Project Templates
The item and project templates are zip files.
4. Copy templates' zip files to the new project directory
5. Set Copy to Output Directory build action to Copy Always
6. Open source.extension.vsixmanifest file
7. Populate the information about the installer
8. Add the template's zip to Assets based on the type of the template.
8.1. In our case, we choose Microsoft.VisualStudio.ProjectTemplate, but you can pick a type for item template or snippet.
8.2. For the source, browse to the file that we added to the project.
9. Set prerequisites for the VSIX installer, which version of Visual Studio will be supported. By default, the latest two versions are set.
10. Build your project
InstallVSIX Extension
After you build your project, a new *.vsix file is generated in the bin folder. You double click on it, and the template will be installed on your machine.
You need to close all instances of Visual Studio or the installation will happen on the next restart of the tool.
After the extension is installed, you can create a new project from the extracted template.
Uninstall VSIX Extension
From Tool -> Extensions and Updates you can find all installed VSIX extensions. From there you can uninstall the extension.
Summary
In the article, we talked about how you can distribute the project/item templates you created among your peers. It is a convenient way to speed up tests writing and applying common team's coding/quality standards.
Published at DZone with permission of Anton Angelov, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments