简体   繁体   English

如何使用.VSIX软件包中的内容?如何获取vsix安装路径

[英]How to use content in .VSIX package?how to get vsix install path

NOW I use this way add folder in .VSIX package. 现在,我使用这种方式在.VSIX包中添加文件夹。

<Content Include="..\..\MyContentFiles\**\*.*">
  <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

After I installed the VSIX, I can find extension in this path \\Users<UserName>\\Appdata\\Local\\Microsoft\\VisualStudio\\10.0Exp\\Extensions\\Microsoft\\<GPName> but I can't get the folder path in vsix code(some python script in this folder,the extension need get this folder install path). 安装VSIX之后,我可以在此路径\\Users<UserName>\\Appdata\\Local\\Microsoft\\VisualStudio\\10.0Exp\\Extensions\\Microsoft\\<GPName>找到扩展名,但无法在vsix代码中获得文件夹路径(此文件夹中有一些python脚本,扩展名需要获取此文件夹的安装路径)。

I try use : 我尝试使用:

System.AppDomain.CurrentDomain.BaseDirectory, System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName,
System.Environment.CurrentDirectory,
System.IO.Directory.GetCurrentDirectory,
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase

but they all return this path 但他们都返回这条路

C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE... C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ Enterprise \\ Common7 \\ IDE ...

so how to get vsix install path and how to use content in .VSIX? 那么如何获取vsix安装路径以及如何在.VSIX中使用内容?

The question has been solved now. 现在问题已经解决。

I use this api get vsix install physical path: 我使用此api获取vsix安装物理路径:

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

path = \\AppData\\Local\\Microsoft\\VisualStudio...\\Extensions[install path]\\xx.dll 路径= \\ AppData \\ Local \\ Microsoft \\ VisualStudio ... \\ Extensions [安装路径] \\ xx.dll

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM