'Export C# Project as .EXE file

I have a C# project in Visual Studio 2019 that I wish to export as a .EXE file. I have already run it in 'Release' Mode, but no .exe turns up in the 'bin' folder - just a '.deps', '.dll', '.pdb', '.runtimeconfig.dev' and a '.runtimeconfig'. I believe I am using a trial for the Enterprise version - does the trial allow this exporting? Thanks.



Solution 1:[1]

Likely you have a library project as part of the solution and you are looking in the library's bin folder for the exe. It will not be there if that is the case. You will only find the dll in that bin folder.

1 - Right Click your project that youre expecting the output to be an EXE step 1

2 - Click "Open Folder in File Explorer" step 2

3 - you should see a bin folder here, navigate in and you'll find your Release and Debug folders.

Solution 2:[2]

Per the comments:

Terminology

The process of converting source code to a binary (exe, dll, etc) is called compiling or building the code, rather than exporting it.

Command Line

To build the code from the command line you can run dotnet publish:

dotnet publish -r win-x64 -c Release --self-contained

By targeting the Windows platform (set by the -r / --runtime parameter) a program will become an executable. Other platforms don't use exe files; so a non runtime specific build would create a dll as that can be used on a variety of platforms.

CS Project File

  • Open your project's .csproj file in an editor.
  • Amend file's OutputType to WinExe (Windows Application) or Exe (Console Application).

IDE UI

You can update the CS Project File by editing it directly, or by navigating the to the relevant settings in your IDE. Assuming that's Visual Studio:

  • Open the Solution Explorer window
  • Right-click on the project & click Properties
  • Select the Application section
  • Amend the Output Type property to Windows Application or Console Application.

Screenshot of Visual Studio 2019 IDE showing the above forms

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CarCar
Solution 2