简体   繁体   中英

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

WPF support was added in .net Core 3.0

Can i compile wpf application on Linux or in Linux-based docker container?

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.

Sorry but the UI frameworks WinForms and WPF are Windows only even when using .NET Core.

Related:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM