gerthmar
gerthmar

Reputation: 36

Invoke debug session for C# command line application in Visual Studio

I am looking for a way to start a debug session of a c# command line application in Visual Studio 2015, without having to go thorugh the project settings dialog and change the command line arguments setting.

The idea is to type the command line arguments on a console inside of Visual Studio and on <ENTER> to start the debugging session with the given arguments.

Upvotes: 1

Views: 237

Answers (3)

AntiHeadshot
AntiHeadshot

Reputation: 1130

By using #if DEBUG you can override the passed arguments when the code is run in debug-mode. When you build a release verison this code is omitted.

Put this at the start of your Main method

#if DEBUG
    args = new string[]{"arg1","arg2"};
#endif

Upvotes: 1

Dan Tromp
Dan Tromp

Reputation: 199

Using System.Diagnostics;

Debugger.Launch();

Debugger.Break(); - This will prompt the debug session

I am not sure this is will prompt the debug in your command line app but this will invoke the debug to catch when it hits the Debugger.Break()..

Upvotes: 0

Oliver
Oliver

Reputation: 45091

Unfortunately this doesn't exists.

But gladly you could write your own Visual Studio Extension.

Upvotes: 0

Related Questions