Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross compile dotnet core app from Windows to Linux

I am working in Windows and want to build a dotnet core app on Windows to run on Linux. In the build folder, I see .DLL file references in the published folder, which would obviously not work on Linux - how do I compile the app from my Windows environment to run on Linux? Is it possible?

In the project.json file there is runtime versions specified, which I believe correlates to the runtimes in the C:\Program Files\dotnet\sdk\1.0.0-preview2-003121\runtimes location? If so, how do I get the Linux runtime installed in Windows and reference it?

like image 611
Johan Foley Avatar asked Aug 02 '16 10:08

Johan Foley


People also ask

Is .NET Core compatible with Linux?

NET Core runtime allows you to run applications on Linux that were made with .

How is .NET Core cross-platform?

NET Core is cross-platform. It runs on Windows, OS X and multiple distributions of Linux. It also supports different CPU architectures. We're adding more Linux distribution and CPU architecture support with the eventual goal of .


Video Answer


1 Answers

You can create self contained applications using publish command.

For example (.Net Core 2.0):

dotnet publish -c release -r win7-x64
dotnet publish -c release -r centos.7-x64

You need to specify win7-x64 OR centos.7-x64 in RuntimeIdentifiers also in the .csproj file.

For more help check this page.

like image 134
Harit Kumar Avatar answered Sep 17 '22 04:09

Harit Kumar