How get the current running Visual Studio installation path from VSPackage

前端 未结 3 1459
梦毁少年i
梦毁少年i 2021-01-13 20:47

I\'ve created a VSPackage which should copy some XML schema files to Visual Studio\'s installation path: %VS install path% \\Xml\\Schemas.

3条回答
  •  一整个雨季
    2021-01-13 21:32

    Finally managed to find the installation path with the following code:

       var test = ((EnvDTE.DTE)ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE).GUID)).FullName;
       VISUAL_STUDIO_INSTALLATION_PATH = Path.GetFullPath(Path.Combine(test, @"..\..\..\"));
    

    Also for getting the Version of the running Visual Studio:

     EnvDTE.DTE dte = (EnvDTE.DTE)Package.GetGlobalService(typeof(EnvDTE.DTE));
     VISUAL_STUDIO_VERSION = dte.Version;
    

提交回复
热议问题