Search code examples
c#.netvisual-studio-extensionsvsix

How to run current project by visual studio extension


I have a console application which generates json.

I need to execute this application by using a Visual Studio extension (Vsix). For that I created a VSix project with command. 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
}

Solution

  • 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();