3

In .NET framework when we build our solution/project, we get an exe in the debug/release folder and we can run our application by double clicking that exe. But how can we do this in .NET core, i know we can't have an exe in .NET core because it is windows specific. When i build my .NET core application i get the following files in the debug folder.enter image description here

I know how to run this application using command prompt but i want to have a file like exe by clicking which i can run my application.

Waleed Naveed
  • 2,293
  • 2
  • 29
  • 57

2 Answers2

3

You can generate exe (self-contained application).

.NET Core 2.0 + Open Package Manager Console or any other console in your project directory and type:

dotnet publish -c Release -r win10-x64
dotnet publish -c Release -r ubuntu.16.10-x64

When you use previous version of .NET Core you have to add runtime identifier of the target environment in csproj:

<PropertyGroup>
    <RuntimeIdentifiers>win10-x64;ubuntu.16.10-x64</RuntimeIdentifiers>
</PropertyGroup>

Runtime Identifiers (RIDs) list: https://learn.microsoft.com/en-us/dotnet/core/rid-catalog

  • Please use `linux-x64` instead of an os-specific RID like `ubuntu.16.10-x64`. The first one will run on all new-ish linux distributions. The second wont even run on the next version of ubuntu. – omajid Nov 26 '18 at 16:48
1

One simple solution is to create a .bat file with runs the dll via the dotnet cli, then you get "a file like exe"

dotnet ConsoleApp2.dll
Marcus Höglund
  • 16,172
  • 11
  • 47
  • 69