How can I dynamically provide command line arguments during VS 2012 C# debug sessions?

1.1k Views Asked by At

I am busy with a console application, being a CLI to an API class that provides top level public methods for a data integration process. During development, it is necessary for me to frequently change the command line arguments in the project settings, debug section.

I am looking for a way to do this dynamically while avoiding the cost of a rebuild after each change a clumsy solution such as explicitly setting values in the string[] args parameter list for entry point Main.

The first solution that springs to mind is a custom config section in app.config, where I can define a collection of various command lines, each being a list of name-value pairs, and specify in an attribute of the command line collection which one should be active. The active command's name-value pairs will then be dynamically injected into said string[] args parameter list by static, non-changing code.

Is there any other way to achieve this?

1

There are 1 best solutions below

1
On

one thing I can think of is using quickwatch to alter the commandline array

Suppose you have the following code:

public static void Main(string[] arg)
{
    string s = arg[0];
}

Put a breakpoint on the first line and press shift f9 after selecting arg. This will open the quickwatch and in the expression field reallocate the array while copying the old values into it.

arg = new string[3] { arg[0], arg[1], "test" }