Reputation: 48076
Sorry my title is rather vague but I don't know how to concisely label what I want to do.
I have a winform application which were trying to dual-purpose so it can also be run as a command line utility by our automation system. In the programs Main()
I am conditionally executed the desired code. The only problem is that (despite logging to Console) a command window is not being launched. What do I need to do to make the application launch a command window and direct stdout to that?
Below is my main (HeadlessExecution is correctly being executed):
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (!ValidateCommandLineArgs())
Application.Run(new TestResultForm());
else
{
HeadlessExecution();
}
}
Upvotes: 3
Views: 552
Reputation: 498904
Extract all the logic into a different, class assembly.
Reference this assembly in a winforms and in a console application. Voila.
Upvotes: 4