How to: Distribute Code Snippets
You can simply give your code snippets to your friends and have them install the snippets on their own computers by using the Code Snippet Manager. However, if you have several snippets to distribute, you can automate the process by including your snippet file in a Visual Studio installer (.vsi) file, which users can install into any edition of Visual Studio by using the Visual Studio Content Installer. For more information about the Visual Studio Content Installer, see How to: Package Components to Use the Visual Studio Content Installer.
Adding a .vscontent File
You need to include a manifest with the file extension .vscontent in your .vsi file. Here is the template you can use to create the file:
<VSContent xmlns="https://schemas.microsoft.com/developer/vscontent/2005">
<Content>
<FileName> </FileName>
<DisplayName> </DisplayName>
<Description> </Description>
<FileContentType> </FileContentType>
<ContentVersion>2.0</ContentVersion>
<Attributes>
<Attribute name="lang" value=""/>
</Attributes>
</Content>
</VSContent>
In this how-to we will use the code snippet created in Walkthrough: Creating a Code Snippet.
To Create a .vscontent File
Create a new XML file and name it VBSnippet.vscontent.
Add the template shown above.
Fill in the fields:
FileName - VBCodeSnippet.snippet
Display Name - VB Code Snippet
Description - Visual Basic code snippets.
FileContentType - Code Snippet
Content Version - use 2.0 if the snippet should be used in Visual Studio 2008 or later, or 1.0 if it can be used in Visual Studio 2005.
Attribute - "vb"
Save the file.
Creating a .vsi File
The .vsi file is really a .zip file with a different extension.
Add the files VBSnippet.vscontent and VBCodeSnippet.snippet into a zip file named VBCodeSnippet.zip.
Rename VBCodeSnippet.zip to VBCodeSnippet.vsi.
This is all you need for a functional .vsi file. However, if you want to display publisher information for your code snippet in the Visual Studio Content Installer, you must sign the .vsi file. For more information, contact a Digital Certificate vendor.
Deploying the .vsi File
Copy the .vsi file to any location on a computer that has Visual Studio installed.
Double-click the .vsi file.
The Visual Studio Content Installer window appears.
If the Hello World Snippet file is not selected, select it and click Next.
If the .vsi is not signed, you will see a warning dialog box named No Signature Found. To continue, click Yes.
The following window shows installation locations for the snippet. Select My Code Snippets and click Next.
The following window indicates whether or not the installation was successful. Click Finish, then Close.
You should see the snippet installed in the Code Snippets Manager under Visual Basic My Code Snippets.