Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where are custom extensions installed in visual studio?

Where are custom extensions installed in Visual Studio? I know you could get path though ExtensionManager.GetInstalledExtensions(), however it seems none of the paths found corresponds to my extension.

like image 381
Yituo Avatar asked Jun 16 '16 02:06

Yituo


People also ask

Where are 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.


2 Answers

Extensions (if deployed as VSIX) will be installed to the user´s profile; each extension will be installed into a folder with a random name, for instance:

%LocalAppData%\Microsoft\VisualStudio\12.0\Extensions\s5lxc0ne.1kp

If you want to obtain the package installation path at runtime, you can obtain that information from the assembly that defines the Package class.

static string GetAssemblyLocalPathFrom(Type type)
{
    string codebase = type.Assembly.CodeBase;
    var uri = new Uri(codebase, UriKind.Absolute);
    return uri.LocalPath;
}

...

string installationPath = GetAssemblyLocalPathFrom(typeof(MyPackage));
like image 90
Matze Avatar answered Oct 03 '22 08:10

Matze


1- Find your package... Let's say your package is MyExtensionPackage.

public sealed class MyExtensionPackage : Package
{
     //...
}

public static string GetExtensionInstallationDirectoryOrNull()
{
    try
    {
        var uri = new Uri(typeof(MyExtensionPackage).Assembly.CodeBase, UriKind.Absolute);
        return Path.GetDirectoryName(uri.LocalPath);
    }
    catch 
    {
        return null;
    }
}
like image 44
Alper Ebicoglu Avatar answered Oct 03 '22 08:10

Alper Ebicoglu