Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile .NET Core app for Linux on a Windows machine

I'm developing a .NET Core app on a Windows 10 machine (with Visual Studio 2015 update 3 + Microsoft .NET Core 1.0.1 VS 2015 Tooling Preview 2) which should published on an Ubuntu 16 machine. To do that, I have to move my source code to the end machine and compile it there, to get it to run. e.g. I'm not able to compile the code on windows and run it on linux. Question: Is there any way to compile the code on win machine and run it on linux?

like image 206
amiry jd Avatar asked Jan 08 '17 14:01

amiry jd


People also ask

Is .NET Core compatible with Linux?

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


2 Answers

Using dotnet build command, you may specify --runtime flag

-r|--runtime < RUNTIME_IDENTIFIER >

Target runtime to build for. For a list of Runtime Identifiers (RIDs) you can use, see the RID catalog.

RIDs that represent concrete operating systems usually follow this pattern [os].[version]-[arch]

Fo example, to build a project and its dependencies for Ubuntu 16.04 runtime use:

dotnet build --runtime ubuntu.16.04-x64 
like image 168
Set Avatar answered Oct 01 '22 09:10

Set


dotnet publish **path to your solution** --configuration Release --framework netcoreapp3.0 --output .**output path** --self-contained false --runtime linux-x64 --verbosity quiet 
like image 32
Wasyster Avatar answered Oct 01 '22 10:10

Wasyster