Compiling C# + Wpf on Linux in Order to Run on Windows

Compiling C# + WPF on Linux in order to run on Windows

Mono does not, and currently has no plans to support WPF, and by proxy, XAML. Where you might get a break with a subset of XAML is with Silverlight support via Moonlight. See http://www.mono-project.com/WPF for details.

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.

compile c# on linux with wpf

It isn't possible: http://www.mono-project.com/WPF

.NET CI server on Linux for building WPF applications

As we spoke in comments:

To either run or build you would need the same set of dll's (for runtime or compile time) so I think the answer is no. Reason why is because all of the runtime dll's are in GAC which is not available on linux neither is a recent version of .NET libraries. AFAIK you can use wine on LINUX to get .NET 1.1

Is WPF on Linux (already) possible?

You'll have better luck working with Moonlight, which targets the Silverlight API, which is a subset of full WPF.

edit: Sure, Silverlight isn't "intended" for the desktop, but there's no reason why you can't embed a silverlight engine in your application. It's been done before, such as for the Mac NY Times Reader

more edit: see Miguel's post on Standalone Silverlight Applications

How to write programs in C# .NET, to run them on Linux/Wine/Mono?

Have you read about Mono.NET on http://www.mono-project.com?

It allows you to write .NET apps for Linux with minor differences over the Microsoft implementation.
I don't think wine will cope with any of the .NET components.

Just read the documentation before and you have a go.

PS: This also gives you the compatibility list between mono and .NET. http://www.mono-project.com/Compatibility and MoMA(mono migration analyzer) is a tool that will scan any .NET app already created to see if its compatible to deploy on linux.



Related Topics



Leave a reply



Submit