Home > Mobile >  how can i publish a C# .net console app without the console?
how can i publish a C# .net console app without the console?

Time:03-05

I'm using c#, .NET core 3.1, vs-code & windows 10

i want to publish my console application but ensure the console will not open when i run the built project. The current command i usually use to publish an app is: dot net publish -r win-x64 -c Release /p:PublishSingleFile=true.

(yes, i know the .net command is writen that way, its the only way i could get this question to post)

I want the console to not open because i use a separate library to open a window for rendering. I have already looked around and haven't found anything to solve my problem

CodePudding user response:

An easy way to do this is to change <OutputType>Exe</OutputType> to <OutputType>WinExe</OutputType> in your csproj. Once you do that, your application won't open a console window.

Later on, if you want to open a console window for debugging or whatever you can PInvoke AllocConsole().

  • Related