Specify VS extension installation directory name

筅森魡賤 提交于 2019-12-11 02:09:03

问题


After installing extension in VS 2012 it is placed in %userprofile%AppData\Local\Microsoft\VisualStudio\11.0\Extensions\ (or in C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions if it is installed for all users) and in folder with random name like "hilatg23.234" or "kcsuvnvi.qtq". Is there a way to specify the name of this folder and make this extension to install to folder like %userprofile%AppData\Local\Microsoft\VisualStudio\11.0\Extensions\MY_EXTENSION_NAME


回答1:


Hm, don´t think so. The VSIX installer will always choose the installation directory automatically. If you want to let the user decide about the installation folder, you´d need to create a MSI installation package.

A while ago I answered another question regards the package registration; maybe some of the provided information might help to create such a setup. See post at: MSI installed VSPackage is loaded in Experimental Instance only

If you just want to obtain the package installation folder at runtime, you can just get it from the package´s assembly codebase, like:

private static string ObtainInstallationFolder()
{
    Type packageType = typeof(MyPackage);
    Uri uri = new Uri(packageType.Assembly.CodeBase);
    var assemblyFileInfo = new FileInfo(uri.LocalPath);
    return assemblyFileInfo.Directory.FullName;
}    



回答2:


My solution:

I use this api get vsix install physical path:

string path = System.Reflection.Assembly.GetExecutingAssembly().Location;

path = \AppData\Local\Microsoft\VisualStudio\...\Extensions\[install path]\xx.dll


来源:https://stackoverflow.com/questions/19705010/specify-vs-extension-installation-directory-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!