

How to install a Visual Studio extension with templates via an MSI
source link: http://blogs.clariusconsulting.net/kzu/how-to-install-a-visual-studio-extension-with-templates-via-an-msi/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to install a Visual Studio extension with templates via an MSI
November 13, 2013 5:20 pm
The original story around VSIX deployment via an MSI was that simply copying it to the %VSInstallDir%\Common7\Ide\Extensions\Your Company\Your Product\Version was enough. But alas, devil is in the details, and a fairly complex matrix of supported and unsupported features depending on the deployment style is also available on MSDN.
However, whenever templates are involved, the general advise from Microsoft was to just run devenv /setup at the end of your MSI installation. This might have been fine when you were only targeting VS2010, but now with 2010, 2012 and 2013 potentially installed on the machine, running devenv /setup three times in a row can take a LOOONG time (we’re talking several minutes here). And this was unavoidable if you are deploying your templates to Common7\IDE\ProjectTemplates or Common7\IDE\ItemTemplates.
But how does VS work its magic when you install a VSIX file? It’s super fast, so it surely doesn’t run devenv /setup! In a VSIX extension, templates are deployed together with the extension content, and VS just picks them up automatically on VS restart.
So here’s the trick:
- Install via your MSI all the templates under the same path of your extension, like %VSInstallDir%\Common7\Ide\Extensions\Your Company\Your Product\Version\ItemTemplates | ProjectTemplates
- For VS2010, you will need to deploy the zipped template files. For VS2012+ you can deploy the content files directly. In both cases, the folder structure will represent the subcategories under which they will appear in the Add New dialogs.
- Remember to point your vsixmanifest to that relative path, like:
<
ItemTemplate
>ItemTemplates</
ItemTemplate
>
<
ProjectTemplate
>ProjectTemplates</
ProjectTemplate
>
- On your MSI project, all you need is a custom action (both install and uninstall) that touches the file %VSInstallDir%\Common7\Ide\Extensions\extensions.configurationchanged. This is the key thing that allows you to avoid running devenv /setup and lets VS know there are new extensions to update. In WIX, the custom action would look like this:
<
CustomAction
Id
=
'VS2012TouchExtensions'
Directory
=
'VS2012_EXTENSIONS_DIR'
Execute
=
"deferred"
Impersonate
=
"no"
ExeCommand
=
'[SystemFolder]cmd.exe /c "copy /b extensions.configurationchanged +,,"'
Return
=
'ignore'
/>
You’d have one such custom action for each VS version, and that’s it
UPDATE: Now that Devenv /UpdateConfiguration
is no longer an undocumented hack, it should be the solution for everyone!
Enjoy!
Recommend
-
61
Tara April 4th, 2019 The March 2019 update of the
-
58
Extension Packs in Visual Studio Code are extremely useful when you want to install a collection of related extensions. In this article, let's walk through the steps of creating an Extension Pack so you can share your fav...
-
69
Tara July 24th, 2019 The July 2019 update of the
-
17
How to transform T4 templates on build without installing a Visual Studio SDK J...
-
13
Visual Studio Code adds extension troubleshooting Latest monthly update to Microsoft’s open source code editor features an extension bisect feature that uses a binary search algorithm to quickly identify an extension causi...
-
9
NUIPreview: a Visual Studio extension to build Tizen.NUI graphical interfaces Dec 22, 2020 • tizen As the last project of 2020, I and some other co-worker...
-
11
5 Visual Studio Code Hacks That You Will Thank Me For (And They're Not Common Points Like "Install Prettier Extension") Jul 11 ...
-
4
0:00 / 28:59 ...
-
5
Enable Group Policy Settings with Visual Studio Administrative Templates (ADMX)
-
6
Visual Studio Code 1.78 debuts profile templates for Python, Java, Angular The April 2023 release of Microsoft’s programming editor also features new def...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK