简体   繁体   中英

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

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

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() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM