我可以在 Linux 中编译 .net Core 3 WPF 应用程序吗?

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

.net Core 3.0 中添加了 WPF 支持

我可以在 Linux 上或在基于 Linux 的 docker 容器中编译 wpf 应用程序吗?

你不能 - 我刚刚在 WSL2 中试过了。 WPF 模板出现在如果您键入 dotnet new

的结果
dotnet new wpf

恢复步骤失败

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. 

此错误是由 SDK 的目标文件本身引发的,因此条件编译无济于事。编译开始前抛出错误。

一个好主意是将项目一分为二,一个 "headless" 库,可以编译、重用和 tested 在任何 OS 和可以在 Window 上构建的 UI 库。

抱歉,UI 框架 WinForms 和 WPF Windows 仅在使用 .NET Core 时也是如此。

相关: