简体   繁体   English

如何通过 Visual Studio 扩展运行当前项目

[英]How to run current project by visual studio extension

I have a console application which generates json.我有一个生成 json 的控制台应用程序。

I need to execute this application by using a Visual Studio extension (Vsix).我需要使用 Visual Studio 扩展 (Vsix) 来执行此应用程序。 For that I created a VSix project with command.为此,我使用命令创建了一个 VSix 项目。 When I click run command, I need to run the current project.当我单击运行命令时,我需要运行当前项目。

I have no idea how to do that.我不知道该怎么做。

private void Execute(object sender, EventArgs e)
{
    // Here is my method which is executed when i click it on menu
}

You could try these:你可以试试这些:

using EnvDTE;

..........


DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE;

dte.ExecuteCommand("Debug.Start");

To run the application without debug, you can try this:要在不调试的情况下运行应用程序,您可以尝试以下操作:

 dte.ExecuteCommand("Debug.StartWithoutDebugging");

And it will debug the current active project when you click the button.当您单击按钮时,它将调试当前活动的项目。

More info, you can refer to this similar issue .更多信息,你可以参考这个类似的问题

========================================= ==========================================

And also you could try to use this:也可以尝试使用这个:

dte.Solution.SolutionBuild.Run();

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

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