I have a single dotnet-core GUI application that depending on the argument parameters it may show only the GUI interface (done with Avalonia framework) or if it receives some special arguments then it should work in console-mode and log into the console without showing the GUI.
If I use <OutputType>WinExe</OutputType>, then the GUI shows fine but the app will never log into the console (for example when using Console.WriteLine("some-text")).
This means I need to configure the csproj with <OutputType>Exe</OutputType> in order to be able to log into the console anything, the problem is that when running in GUI mode, along with the GUI application window, another console window pops up which I want to hide to show only the GUI.
In dotnet full-framework 4.X I was able to create WPF apps that did this dual console/gui mode in 1 exe. A possible solution would be if I could make the console window to be hidden when running in GUI mode, or maybe Avalonia-UI/dotnet-core has some other way to do this. Does anyone knows how to this?
UPDATE: Here are some clarifications: The app has 2 modes:
- GUI Mode: if you just double click on the "App.exe" (runs with no args parameters) then the GUI should appear (and only the GUI, not the GUI plus another console window as it currently happens). This would be usually done by setting the csproj as
<OutputType>WinExe</OutputType>, but that makes theConsole.Writefunction not to work when run in the followingConsole Mode. - Console Mode: if an advanced user is trying to use some of the app functions from the console automate something, then the app should behave like a console application, with all the features one would expect like
app.exe -hto show the available commands,app.exe -vto show the version, etc. This means that it is not OK to show some hand-made GUI window displaying the output text or log anywhere else like into a file.
It could be done in 2 separate executable files, but some people like me find some beauty in applications that are just a simple app.exe file.
There are many examples of this dual behavior, like VisualStudio's Nirsoft applications.devenv.exe or