After creating my first console app with .Net Core 1.1 on Windows 10 with Visual Studio 2017 I copied it to my Linux server - Ubuntu 16.04.3 LTS (already with .Net Core framework installed).
I have successfully executed the command:
Windows
>
Dotnet miApp.dll
Linux
$ Dotnet miApp.dll
Now I want to have a standalone executable , without needing dotnet to run. As I do?
I want to perform like this:
Windows
>
MiApp.exe
Linux
$ ./minhaApp
What you need is to compile the console application according to the Self-contained deployment model or Self-Contained Deployment .
The advantage is that it will no longer require .Net Core installed on the target machine and can therefore be run without the need to do so via the dotnet command. The downside is that the executable will no longer be portable and will need to be compiled for each specific platform for which you need the executable.
To do it this way edit your file
.csproj
and add the tag<RuntimeIdentifiers>
inside<PropertyGroup>
and put a list separated by;
the Ids of the platforms you want to compile to. The complete list of ids can be found here: .NET Core Runtime IDentifier (RID) catalogExample of
.csproj
a console appAfter this, compile in Release mode and create as many publication profiles as there are platforms where you are going to compile.
Make sure to put the profiles in different folders and with different platforms.
Windows publishing profile example
Publish profile example in Ubuntu
Finally, the files ready to be deployed will be in the paths that you placed in the publication profiles. Keep in mind that a lot of files are generated (In my case 118 in Windows and 123 in Ubuntu) since they include not only your app but all the .Net Core necessary for the app to be completely self-sufficient.
As I tell you Carlos, you must generate a self-contained application.
By commands you can do it like this
The list of possible values is extensive and of course is updated from time to time. some of the other possible values are these depending on the OS you want to generate the executable to.