[英]How to get project path to exe folder from dte
I write a Visual Studio Extension (Vsix).我编写了一个 Visual Studio 扩展(Vsix)。
What I have done so far:到目前为止我做了什么:
I need to find current running external project path to exe.我需要找到当前运行的外部项目路径到 exe。
My code:我的代码:
private void Execute(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();
// This runs my external console application
dte.Solution.SolutionBuild.Run();
Path.GetDirectoryName(dte.Solution.FullName);
Project prj = dte.Solution.Projects.Item(1);
string msg2, msg3 = "";
msg2 = prj.DTE.FullName;
msg3 = prj.DTE.FileName;
}
Currently project which runs application is devenv.exe so:当前运行应用程序的项目是devenv.exe所以:
Path.GetDirectoryName(dte.Solution.FullName) = "D:\\user\\proj\\projName\\Docs\\App\\AppName" Path.GetDirectoryName(dte.Solution.FullName) = "D:\\user\\proj\\projName\\Docs\\App\\AppName"
I need path to exe..我需要exe的路径..
msg2, msg3 = "D:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\devenv.exe" msg2, msg3 = "D:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\devenv.exe"
Do you have any hints?你有什么提示吗?
Maybe you could use ProcessModule.ModuleName to get the full path of current process.也许您可以使用ProcessModule.ModuleName来获取当前进程的完整路径。
I create a visual studio extension with a menu command, and add this code into Execute method我使用菜单命令创建了一个 Visual Studio 扩展,并将此代码添加到 Execute 方法中
private void Execute(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();
string message = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
string title = "Command1";
...
}
The result:结果:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.