Is it possible to run a .NET Core console application silently (hide console window)?

Solution 1:

Update 2018: In .NET Core 3.0+, you will be able to set <OutputType>WinExe</OutputType> inside of the csproj file.

Currently, this is not directly possible out of the box because Windows EXE files contain a flag indicating if it is a "console" or "GUI" application that Windows evaluates even before starting the application. However, this flag can be changed using editbin.exe (ships with Visual Studio' C++ build tools as far as I know).

Building on this, you could create a self-contained .NET Core application (removing the "type": "platform" from the project.json and adding a runtimes section) so your project output includes an actual .exe file and add a post-build script that invokes editbin.exe /subsystem:windows yourapp.exe.

Solution 2:

I really wanted to do it as Martin resolved, but I couldn't find editbin.exe. Well, I should have run the Visual Studio installer and installed Microsoft Visual C++, but I had limited memory, so I found another way of doing it NSubsys on NuGet.

The application will be made to run in hidden mode on publishing.

Note to copy the Npm install command from NuGet since searching it from package manager for solution didn't seem to find any results.

Solution 3:

With .NET Core 3.0+ (including .NET 5), just do this in csproj:

<OutputType>WinExe</OutputType>