简体   繁体   中英

How to create a new executable C# project with Visual Studio Code

I want to create a new executable project with Visual Studio Code + omnisharp. It works for dll but not for an exe file.

  1. Created a folder for my new project (eg myApp)
  2. Open Visual studio code -> file -> open folder
  3. Open internal VSC terminal and type the following commands

Code:

dotnet new console (pressed yes in popup)
dotnet restore
dotnet run
//hello world was visible in terminal (what means it works)
dotnet build

Build was successful but a dll file was created.

  • Actual result: dll file
  • Expected result: exe file

BTW: I used this for help -> https://github.com/dotnet/docs/blob/master/docs/core/tutorials/with-visual-studio-code.md

You are using dotnet core, so executable files are still in .dll. To run the file, run dotnet nameofdll.dll

dotnet core is cross-platform, and to reduce the tight coupling with windows, .exe is not used for executables anymore.

If you want your application to be Windows dependant, you will need to make your application target .Net Framework instead - you will get a .exe instead this way.

ok heres how i did it

if you go into the folder where the app is and go to bin/debug/net6.0

i found a exe file along with four other files i have no idea what they do

and a file called publish, also try F1 and searching for publish that might make these files appear (publish seems to be the same 5 files outside of the publish file)

and to the people who downvoted my terrible joke to literal extinction

there, ya happy?

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