.Net Core 2.1 produces .dll instead of .exe & RuntimeIdentifiers

hfaun 1 Reputation point
2022-06-15T21:56:54.747+00:00

I have a .NET Core

<Project Sdk="Microsoft.NET.Sdk">

Target framework = .NET Core 2.1
Output type = Console Application

When I compile it I get a dll instead of a exe. I read a post on this forum that you should add <RuntimeIdentifiers> which I did (see below) but I still get a dll. Is .NET Core not meant for console applications or why does that not work? Also why do I need to define OSs and bitness? I though .NET anything produces bytecode which then on first execution is translated to machine code.

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<ApplicationIcon />
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
</PropertyGroup>

<ItemGroup>
<snip>
</ItemGroup>
</Project>

.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
291 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ken Tucker 5,801 Reputation points
    2022-06-16T00:15:03.853+00:00

    Dot net core is cross platform. EXEs are a windows thing that is why dlls are created. if want an exe use publish to create it.

     dotnet publish -r win-x64 -p:PublishSingleFile=True   
    

    https://learn.microsoft.com/en-us/dotnet/core/deploying/

    You can run the dll like this

      dotnet MyApp.dll