question

hfaun-1603 avatar image
0 Votes"
hfaun-1603 asked JackJJun-MSFT commented

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

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>

dotnet-cli
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@hfaun-1603, is any update?

0 Votes 0 ·

1 Answer

vb2ae avatar image
0 Votes"
vb2ae answered vb2ae edited

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://docs.microsoft.com/en-us/dotnet/core/deploying/

You can run the dll like this

   dotnet MyApp.dll
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

FYI .net core 2.1 is out of support recommend using .net core 3.1 or .net 6 instead

0 Votes 0 ·