Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get installed VisualStudio extensions programmatically?

How can I get a list of installed VisualStudio extensions? Somehow through DTE? Just the names would be fair enough.

like image 506
Matthias Avatar asked Jan 28 '16 20:01

Matthias


People also ask

How do I see installed extensions in VS Code?

Bring up the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of VS Code or the View: Extensions command (Ctrl+Shift+X). This will show you a list of the most popular VS Code extensions on the VS Code Marketplace.

Where are VS Code extensions installed Linux?

You can list all the installed extensions using the Command Palette window and Show Installed Extensions commands. However, if you are looking for the physical location for your extensions, you can open the $HOME/. vscode/extensions folder on Mac and Linux or the %USERPROFILE%\.

Where is VSIX installed?

Installation location During installation, Extensions and Updates looks for the contents of the VSIX package in a folder under %LocalAppData%\Microsoft\VisualStudio\14.0\Extensions. By default, the installation applies only to the current user, because %LocalAppData% is a user-specific directory.

How to install an extension programatically in Visual Studio?

But if you want to install an extension programatically, the VSIXInstaller.exe application offers a few command-line switches: Notice the /skuName:<name> option: it allows to specify the exact edition (Enterprise, Premium, Pro, Community, etc.) of Visual Studio where you want to install the extension. Which value you would need to use?

Where can I find more information about Visual Studio extensions?

You can find more information about Visual Studio extensions here: Visual Studio SDK. Use the Extensions and Updates dialog box to install and manage Visual Studio extensions. To open the Extensions and Updates dialog, choose Tools > Extensions and Updates, or type Extensions in the Quick Launch search box.

How do I update an extension in Visual Studio?

Automatic extension updates. Extensions are automatically updated when a new version is available on Visual Studio Marketplace. The new version of the extension is detected and installed in the background. The next time you open Visual Studio, the new version of the extension will be running.

How do I disable the Visual Visual Studio extension?

Visual Studio disables the extension and lets you know whether you need to restart your system for the disabling to take effect. You can re-enable the extension in the Tools > Extensions and Updates dialog box if you want. Choose Disable this extension.


2 Answers

Does this help:

System.IServiceProvider serviceProvider = package as System.IServiceProvider;
    Microsoft.VisualStudio.ExtensionManager.IVsExtensionManager em =
       (Microsoft.VisualStudio.ExtensionManager.IVsExtensionManager)serviceProvider.GetService(
            typeof(Microsoft.VisualStudio.ExtensionManager.SVsExtensionManager));

    string result = "";
    foreach(Microsoft.VisualStudio.ExtensionManager.IInstalledExtension i in em.GetInstalledExtensions())
    {
        Microsoft.VisualStudio.ExtensionManager.IExtensionHeader h = i.Header;
        if (!h.SystemComponent)
            result += h.Name + " (by " + h.Author + ") v" + h.Version + " " + h.MoreInfoUrl + System.Environment.NewLine;
    }

Copied from https://vlasovstudio.com/visual-commander/commands.html #20.

like image 131
D.R. Avatar answered Oct 20 '22 17:10

D.R.


Another possibility, if you don't want DTE, because you are not running from within Visual Studio or are concerned about performance you can query the extensions from the file system / registry:

For User Extensions %LocalAppData%\Microsoft\VisualStudio*.vsix

For General Extensions \Common7\IDE\Extensions*.vsix

IF you want to be 100% correct you can look up the paths in \Common7\IDE\devenv.pkgdef

NOTE: There can be additional paths in the PkgDefSearchPath.

To check wether a User Extensions is enabled or not you have to query the registry: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\ExtensionManager\EnabledExtensions

There are some other rules that apply, which you can find in this blog from Microsoft: http://blogs.msdn.com/b/visualstudio/archive/2010/02/19/how-vsix-extensions-are-discovered-and-loaded-in-vs-2010.aspx

like image 36
Inspyro Avatar answered Oct 20 '22 15:10

Inspyro