How to Compile .Net Core App for Linux on a Windows MAChine

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

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

Dotnet core 2.1 code build for Linux from Windows machine

You cannot build on Windows and deploy the same on to Linux.

For eg: dotnet build --runtime ubuntu.16.04-x64

Look into the following on how to build specific to linux

Can i compile .net Core 3 WPF application in Linux?

You can't - I just tried this in WSL2. The WPF templates appear in if you type dotnet new but the result of

dotnet new wpf

fails in the restore step

The template "WPF Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on wpftest/wpftest.csproj...
/usr/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(59,5):
error NETSDK1100: Windows is required to build Windows desktop applications.

This error is thrown by the SDK's targets file itself so conditional compilation won't help. The error is thrown before compilation starts.

A good idea would be to split the project in two, a "headless" library that can be compiled, reused and tested in any OS and a UI library that can be built on Window.

Can I build .net core project for Mac on Windows?

As far as I know, the asp.net core application is a cross-platform developer platform, that means you could develop your application on any platform and running the application on any platform.

You could build the application on the windows platform and use publish to publish the application.

Then you could install the .NET Core MAC SDK and using dotnet to run the application.

More details, you could refer to this article.



Related Topics



Leave a reply



Submit