Search code examples
c#dllvisual-studio-codeexeomnisharp

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 (e.g. 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


Solution

  • 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.