.NET Core auto executable

2

After creating my first .NET console application on Windows 10 with Visual Studio 2017 I copied it to my Linux - Ubuntu 16.04.3 LTS server (already with .NET Core installed).

I successfully ran the command:

Windows

> dotnet minhaApp.dll

Linux

$ dotnet minhaApp.dll

Now I want to have an independent executable , without needing dotnet to run. How do I?

I want to do this:

Windows

> minhaApp.exe

Linux

$ ./minhaApp
    
asked by anonymous 20.08.2017 / 00:18

1 answer

2

It changes almost nothing. Normally you should set yourself targeting a version of .NET Core itself. What changes is specifying where to run.

For Windows just give this command:

dotnet publish -c Release -r win10-x64

For Linux just change the target, but I never did, probably ubuntu.16.04-x64 ( see the catalog ).

Before you need to set csproj to the desired targets, something like this:

<PropertyGroup>
    <RuntimeIdentifiers>win10-x64/RuntimeIdentifiers>
</PropertyGroup>

The rest is equal to what you already know how to do.

Documentation .

    
20.08.2017 / 00:40