tech.guitarrapc.cóm

Technical updates

.NET 7 で WPF を Linux ビルドする

.NET 7 のリリースノートを見ているとふとWPFがあったので覗いてみると気になるリリースが含まれています。

devblogs.microsoft.com

引用: https://devblogs.microsoft.com/dotnet/wpf-on-dotnet-7/

Improve Linux build とは。.NET 7 で WPF がビルドできるようになったのかしら?

ということで見てみましょう。

tl;dr;

.NET 7 から、WPF アプリ/ライブラリを Linux でビルドできるようになっています。(vcxproj はコンパイルできない)

Linux ビルドには3つの条件を満たす必要があるようです。

  • csproj の TargetFramework は <TargetFramework>net7.0-windows</TargetFramework> (デフォルトのまま)
  • csproj に <EnableWindowsTargeting>true</EnableWindowsTargeting> のエントリーをPropertyGroup に追加する
  • .NET 7 SDK がインストールされた Linux 環境を用意する

あとは、dotnet build を行えばビルドできます。

ただし、このままLinux でビルドしても成果物は Linux向けなので、Windowsアーキテクチャ向けにランタイム識別子 もビルド時に指定しましょう。

  • dotnet publish -r win-x64 --no-self-contained (--self-contained でも必要な方で)

夢にまで見た Linux で WPF をビルドして、Windows で実行する環境がそこにあります。

サンプルリポジトリ

リポジトリおいておきます。

github.com

GitHub Ations のUbuntu-22.04 環境でビルドしたWPF 成果物は Actions からダウンロードできます。(成果物による一切に関して責任は取りません。といういつものは前置きしておきます)

Windows で実行できるのが確認できるでしょう。

.NET 6 では WPF を Linuxビルドできたことがない

私の認識と.NET 6 検証用 GitHub Actions/WSL2/Docker 環境では WPF アプリ/ライブラリを Linux ビルド成功したことはなくできない認識でした。

おおむねこのIssue と同じです。

github.com

.NET 7 で導入された WPF の Linux ビルド対応

次の PR で対応がされています。

github.com

内容だけ見ると .NET6 でも実はできてたのでは 1 という感じですが、とりあえずパッと作ってビルドできないのでそういうものなんでしょう。現実です。

.NET 7 で WPFアプリ をLinuxビルドする

WPF アプリを生成してサクッとやってみましょう。2

以降、誰でも試せるように docker を用いて実際の作業を示します。成果物を Windows に持ってきたいなら適当にボリュームマウントしてください。

docker run -it mcr.microsoft.com/dotnet/sdk:7.0 /bin/bash

まずは WPF のプロジェクトを .NET 7 で作成します。 このまま、 Linux の .NET 7 SDK でビルドしようとしてもエラーが出ます。

$ mkdir -p /home/WpfApp
$ cd /home/WpfApp
$ dotnet new wpf
$ ls -l
total 4
-rwxrwxrwx 1 foo foo  366 Nov 11 02:10 App.xaml
-rwxrwxrwx 1 foo foo  339 Nov 11 02:10 App.xaml.cs
-rwxrwxrwx 1 foo foo  604 Nov 11 02:10 AssemblyInfo.cs
-rwxrwxrwx 1 foo foo  491 Nov 11 02:10 MainWindow.xaml
-rwxrwxrwx 1 foo foo  658 Nov 11 02:10 MainWindow.xaml.cs
drwxrwxrwx 1 foo foo 4096 Nov 11 02:10 obj
-rwxrwxrwx 1 foo foo  245 Nov 11 02:10 WpfApp.csproj

$ dotnet build
... 省略...
Error: /home/runner/.dotnet/sdk/7.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error NETSDK1100: To build a project targeting Windows on this operating system, set the EnableWindowsTargeting property to true. [/home/WpfApp/WpfApp.csproj]

エラーには、EnableWindowsTargeting プロパティを true で設定しろとあります。実際今の csproj を見てみると初期状態にはないプロパティですね。

$ cat WpfApp.csproj
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net7.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

</Project>

csproj に、EnableWindowsTargeting を true と設定してから、もう一度ビルドしてみましょう。 今回は sed で適当に追加しちゃいますが、VS Code や Vim でもなんでもいいでしょう。

$ sed -i '/<UseWPF>.*/a \ \ \ \ <EnableWindowsTargeting>true<\/EnableWindowsTargeting>' WpfApp.cspr
oj
$ cat WpfApp.csproj
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net7.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWPF>true</UseWPF>
    <EnableWindowsTargeting>true</EnableWindowsTargeting>
  </PropertyGroup>

</Project>

$ dotnet build
... 省略...
WpfApp -> /home/WpfApp/bin/Release/net7.0-windows/WpfApp.dll

$ dotnet publish
MSBuild version 17.4.0+18d5aef85 for .NET
  Determining projects to restore...
  Restored /src/WpfApp.csproj (in 1.65 sec).
  WpfApp -> /home/WpfApp/bin/Release/net7.0-windows/WpfApp.dll
  WpfApp -> /home/WpfApp/bin/Release/net7.0-windows/publish/

ビルドがうまくいきましたね。しかし、成果物は次のように.exe ではないようです。

$ ls -l /home/WpfApp/bin/Release/net7.0-windows/publish
total 212
-rwxr-xr-x 1 foo foo 181016 Nov 10 17:32 WpfApp
-rw-r--r-- 1 foo foo    388 Nov 10 17:32 WpfApp.deps.json
-rw-r--r-- 1 foo foo   7168 Nov 10 17:32 WpfApp.dll
-rw-r--r-- 1 foo foo  13860 Nov 10 17:32 WpfApp.pdb
-rw-r--r-- 1 foo foo    355 Nov 10 17:32 WpfApp.runtimeconfig.json

Windows 向けにビルドするように、ランタイムに win-x64 を指定しましょう。これで .exe が生成されます。

$ dotnet publish -r win-x64 --no-self-contained
/usr/share/dotnet/sdk/7.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(574,5): warning NETSDK1074: The application host executable will not be customized because adding resources requires that the build be performed on Windows (excluding Nano Server). [/home/WpfApp.csproj]
  WpfApp -> /home/WpfApp/bin/Release/net7.0-windows/WpfApp.dll
  WpfApp -> /home/WpfApp/bin/Release/net7.0-windows/publish/

$ ls -l /home/WpfApp/bin/Debug/net7.0-windows/win-x64/publish/
total 170
-rwxr-xr-x 1 foo foo    440 Nov 10 17:48 WpfApp.deps.json
-rwxr-xr-x 1 foo foo   6656 Nov 10 17:48 WpfApp.dll
-rwxr-xr-x 1 foo foo 152064 Nov 10 17:48 WpfApp.exe
-rwxr-xr-x 1 foo foo  13808 Nov 10 17:48 WpfApp.pdb
-rwxr-xr-x 1 foo foo    252 Nov 10 17:48 WpfApp.runtimeconfig.json

Windows で WpfApp.exe も実行できますね、やったー。

Linux でビルドした WpfApp を Windows で実行

--self-contained でも同様にLinuxでビルド、成果物をWindowsで実行できます。

$ dotnet publish -r win-x64 --self-contained
/usr/share/dotnet/sdk/7.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(574,5): warning NETSDK1074: The application host executable will not be customized because adding resources requires that the build be performed on Windows (excluding Nano Server). [/home/WpfApp.csproj]
  WpfApp -> /home/WpfApp/bin/Release/net7.0-windows/WpfApp.dll
  WpfApp -> /home/WpfApp/bin/Release/net7.0-windows/publish/

$ ls -l /home/WpfApp/bin/Debug/net7.0-windows/win-x64/publish/
total 144999
-rwxr-xr-x 1 root root    21120 Oct 19 01:23 Accessibility.dll
-rwxr-xr-x 1 root root  4916728 May  6  2022 D3DCompiler_47_cor3.dll
-rwxr-xr-x 1 root root   522416 Oct 19 14:40 DirectWriteForwarder.dll
-rwxr-xr-x 1 root root  1058976 Oct 18 17:01 Microsoft.CSharp.dll
-rwxr-xr-x 1 root root  1813896 Dec 16  2020 Microsoft.DiaSymReader.Native.amd64.dll
-rwxr-xr-x 1 root root  1296512 Oct 18 17:01 Microsoft.VisualBasic.Core.dll
-rwxr-xr-x 1 root root   247968 Oct 19 14:40 Microsoft.VisualBasic.Forms.dll
-rwxr-xr-x 1 root root    19072 Oct 19 01:24 Microsoft.VisualBasic.dll
-rwxr-xr-x 1 root root    16032 Oct 18 16:21 Microsoft.Win32.Primitives.dll
-rwxr-xr-x 1 root root    39072 Oct 19 14:40 Microsoft.Win32.Registry.AccessControl.dll
-rwxr-xr-x 1 root root   129168 Oct 18 17:01 Microsoft.Win32.Registry.dll
-rwxr-xr-x 1 root root   112800 Oct 19 14:40 Microsoft.Win32.SystemEvents.dll
-rwxr-xr-x 1 root root   158896 Oct 19 04:32 PenImc_cor3.dll
-rwxr-xr-x 1 root root  8616056 Oct 19 14:40 PresentationCore.dll
-rwxr-xr-x 1 root root    39088 Oct 19 14:40 PresentationFramework-SystemCore.dll
-rwxr-xr-x 1 root root    34952 Oct 19 14:40 PresentationFramework-SystemData.dll
-rwxr-xr-x 1 root root    34976 Oct 19 14:40 PresentationFramework-SystemDrawing.dll
-rwxr-xr-x 1 root root    34960 Oct 19 14:40 PresentationFramework-SystemXml.dll
-rwxr-xr-x 1 root root    30848 Oct 19 14:40 PresentationFramework-SystemXmlLinq.dll
-rwxr-xr-x 1 root root   456864 Oct 19 14:40 PresentationFramework.Aero.dll
-rwxr-xr-x 1 root root   460936 Oct 19 14:40 PresentationFramework.Aero2.dll
-rwxr-xr-x 1 root root   239776 Oct 19 14:40 PresentationFramework.AeroLite.dll
-rwxr-xr-x 1 root root   272544 Oct 19 14:40 PresentationFramework.Classic.dll
-rwxr-xr-x 1 root root   682120 Oct 19 14:40 PresentationFramework.Luna.dll
-rwxr-xr-x 1 root root   338080 Oct 19 14:40 PresentationFramework.Royale.dll
-rwxr-xr-x 1 root root 16226464 Oct 19 14:40 PresentationFramework.dll
-rwxr-xr-x 1 root root  1234088 Oct  7 03:04 PresentationNative_cor3.dll
-rwxr-xr-x 1 root root  1288352 Oct 19 14:40 PresentationUI.dll
-rwxr-xr-x 1 root root  1628288 Oct 19 14:40 ReachFramework.dll
-rwxr-xr-x 1 root root    15520 Oct 18 16:21 System.AppContext.dll
-rwxr-xr-x 1 root root    15520 Oct 18 16:21 System.Buffers.dll
-rwxr-xr-x 1 root root   493728 Oct 19 14:40 System.CodeDom.dll
-rwxr-xr-x 1 root root   264336 Oct 18 17:01 System.Collections.Concurrent.dll
-rwxr-xr-x 1 root root   694416 Oct 18 17:01 System.Collections.Immutable.dll
-rwxr-xr-x 1 root root   108720 Oct 18 17:02 System.Collections.NonGeneric.dll
-rwxr-xr-x 1 root root   108688 Oct 18 17:02 System.Collections.Specialized.dll
-rwxr-xr-x 1 root root   268464 Oct 18 17:01 System.Collections.dll
-rwxr-xr-x 1 root root   198824 Oct 18 17:02 System.ComponentModel.Annotations.dll
-rwxr-xr-x 1 root root    17536 Oct 18 16:21 System.ComponentModel.DataAnnotations.dll
-rwxr-xr-x 1 root root    47232 Oct 18 17:02 System.ComponentModel.EventBasedAsync.dll
-rwxr-xr-x 1 root root    84136 Oct 18 17:02 System.ComponentModel.Primitives.dll
-rwxr-xr-x 1 root root   755856 Oct 18 17:02 System.ComponentModel.TypeConverter.dll
-rwxr-xr-x 1 root root    30888 Oct 18 17:02 System.ComponentModel.dll
-rwxr-xr-x 1 root root  1087616 Oct 19 14:40 System.Configuration.ConfigurationManager.dll
-rwxr-xr-x 1 root root    20128 Oct 18 16:21 System.Configuration.dll
-rwxr-xr-x 1 root root   186536 Oct 18 17:02 System.Console.dll
-rwxr-xr-x 1 root root    24224 Oct 18 16:21 System.Core.dll
-rwxr-xr-x 1 root root  3016864 Oct 18 17:02 System.Data.Common.dll
-rwxr-xr-x 1 root root    16000 Oct 18 16:21 System.Data.DataSetExtensions.dll
-rwxr-xr-x 1 root root    25712 Oct 18 16:21 System.Data.dll
-rwxr-xr-x 1 root root    21648 Oct 19 01:24 System.Design.dll
-rwxr-xr-x 1 root root    16504 Oct 18 16:21 System.Diagnostics.Contracts.dll
-rwxr-xr-x 1 root root    16000 Oct 18 16:21 System.Diagnostics.Debug.dll
-rwxr-xr-x 1 root root   391344 Oct 18 17:02 System.Diagnostics.DiagnosticSource.dll
-rwxr-xr-x 1 root root   800896 Oct 18 16:17 System.Diagnostics.EventLog.Messages.dll
-rwxr-xr-x 1 root root   383104 Oct 19 14:40 System.Diagnostics.EventLog.dll
-rwxr-xr-x 1 root root    47264 Oct 18 17:02 System.Diagnostics.FileVersionInfo.dll
-rwxr-xr-x 1 root root   305312 Oct 19 14:40 System.Diagnostics.PerformanceCounter.dll
-rwxr-xr-x 1 root root   346288 Oct 18 17:02 System.Diagnostics.Process.dll
-rwxr-xr-x 1 root root    47248 Oct 18 17:02 System.Diagnostics.StackTrace.dll
-rwxr-xr-x 1 root root    75936 Oct 18 17:03 System.Diagnostics.TextWriterTraceListener.dll
-rwxr-xr-x 1 root root    16032 Oct 18 16:21 System.Diagnostics.Tools.dll
-rwxr-xr-x 1 root root   149672 Oct 18 17:03 System.Diagnostics.TraceSource.dll
-rwxr-xr-x 1 root root    16512 Oct 18 16:21 System.Diagnostics.Tracing.dll
-rwxr-xr-x 1 root root  1083536 Oct 19 14:40 System.DirectoryServices.dll
-rwxr-xr-x 1 root root  1493120 Oct 19 14:40 System.Drawing.Common.dll
-rwxr-xr-x 1 root root    15488 Oct 19 01:24 System.Drawing.Design.dll
-rwxr-xr-x 1 root root   137344 Oct 18 17:03 System.Drawing.Primitives.dll
-rwxr-xr-x 1 root root    21112 Oct 19 01:24 System.Drawing.dll
-rwxr-xr-x 1 root root    16512 Oct 18 16:21 System.Dynamic.Runtime.dll
-rwxr-xr-x 1 root root   207008 Oct 18 17:03 System.Formats.Asn1.dll
-rwxr-xr-x 1 root root   272528 Oct 18 17:03 System.Formats.Tar.dll
-rwxr-xr-x 1 root root    16544 Oct 18 16:21 System.Globalization.Calendars.dll
-rwxr-xr-x 1 root root    15992 Oct 18 16:21 System.Globalization.Extensions.dll
-rwxr-xr-x 1 root root    16000 Oct 18 16:21 System.Globalization.dll
-rwxr-xr-x 1 root root    92336 Oct 18 17:03 System.IO.Compression.Brotli.dll
-rwxr-xr-x 1 root root    15992 Oct 18 16:21 System.IO.Compression.FileSystem.dll
-rwxr-xr-x 1 root root   828064 Oct 18 16:21 System.IO.Compression.Native.dll
-rwxr-xr-x 1 root root    51376 Oct 18 17:03 System.IO.Compression.ZipFile.dll
-rwxr-xr-x 1 root root   276624 Oct 18 17:03 System.IO.Compression.dll
-rwxr-xr-x 1 root root   108720 Oct 18 17:03 System.IO.FileSystem.AccessControl.dll
-rwxr-xr-x 1 root root    55456 Oct 18 17:03 System.IO.FileSystem.DriveInfo.dll
-rwxr-xr-x 1 root root    15992 Oct 18 16:21 System.IO.FileSystem.Primitives.dll
-rwxr-xr-x 1 root root    88240 Oct 18 17:03 System.IO.FileSystem.Watcher.dll
-rwxr-xr-x 1 root root    16032 Oct 18 16:21 System.IO.FileSystem.dll
-rwxr-xr-x 1 root root    92320 Oct 18 17:03 System.IO.IsolatedStorage.dll
-rwxr-xr-x 1 root root    84144 Oct 18 17:03 System.IO.MemoryMappedFiles.dll
-rwxr-xr-x 1 root root   284816 Oct 19 14:40 System.IO.Packaging.dll
-rwxr-xr-x 1 root root    16544 Oct 18 16:21 System.IO.Pipes.AccessControl.dll
-rwxr-xr-x 1 root root   186544 Oct 18 17:03 System.IO.Pipes.dll
-rwxr-xr-x 1 root root    16016 Oct 18 16:21 System.IO.UnmanagedMemoryStream.dll
-rwxr-xr-x 1 root root    16000 Oct 18 16:21 System.IO.dll
-rwxr-xr-x 1 root root  3827872 Oct 18 17:04 System.Linq.Expressions.dll
-rwxr-xr-x 1 root root   850080 Oct 18 17:04 System.Linq.Parallel.dll
-rwxr-xr-x 1 root root   231568 Oct 18 17:04 System.Linq.Queryable.dll
-rwxr-xr-x 1 root root   505984 Oct 18 17:04 System.Linq.dll
-rwxr-xr-x 1 root root   161960 Oct 18 17:04 System.Memory.dll
-rwxr-xr-x 1 root root   108704 Oct 18 17:04 System.Net.Http.Json.dll
-rwxr-xr-x 1 root root  1751184 Oct 18 17:04 System.Net.Http.dll
-rwxr-xr-x 1 root root   706720 Oct 18 17:04 System.Net.HttpListener.dll
-rwxr-xr-x 1 root root   444544 Oct 18 17:04 System.Net.Mail.dll
-rwxr-xr-x 1 root root   116880 Oct 18 17:04 System.Net.NameResolution.dll
-rwxr-xr-x 1 root root   170160 Oct 18 17:04 System.Net.NetworkInformation.dll
-rwxr-xr-x 1 root root   100512 Oct 18 17:04 System.Net.Ping.dll
-rwxr-xr-x 1 root root   227488 Oct 18 17:05 System.Net.Primitives.dll
-rwxr-xr-x 1 root root   268432 Oct 18 17:05 System.Net.Quic.dll
-rwxr-xr-x 1 root root   358520 Oct 18 17:05 System.Net.Requests.dll
-rwxr-xr-x 1 root root   620688 Oct 18 17:05 System.Net.Security.dll
-rwxr-xr-x 1 root root    47264 Oct 18 17:05 System.Net.ServicePoint.dll
-rwxr-xr-x 1 root root   563360 Oct 18 17:05 System.Net.Sockets.dll
-rwxr-xr-x 1 root root   174256 Oct 18 17:05 System.Net.WebClient.dll
-rwxr-xr-x 1 root root    67744 Oct 18 17:05 System.Net.WebHeaderCollection.dll
-rwxr-xr-x 1 root root    47280 Oct 18 17:05 System.Net.WebProxy.dll
-rwxr-xr-x 1 root root   104608 Oct 18 17:05 System.Net.WebSockets.Client.dll
-rwxr-xr-x 1 root root   194696 Oct 18 17:05 System.Net.WebSockets.dll
-rwxr-xr-x 1 root root    18040 Oct 18 16:21 System.Net.dll
-rwxr-xr-x 1 root root    16016 Oct 18 16:21 System.Numerics.Vectors.dll
-rwxr-xr-x 1 root root    15992 Oct 18 16:21 System.Numerics.dll
-rwxr-xr-x 1 root root    84112 Oct 18 17:05 System.ObjectModel.dll
-rwxr-xr-x 1 root root  1001632 Oct 19 14:40 System.Printing.dll
-rwxr-xr-x 1 root root 11651216 Oct 18 16:19 System.Private.CoreLib.dll
-rwxr-xr-x 1 root root  2230432 Oct 18 17:05 System.Private.DataContractSerialization.dll
-rwxr-xr-x 1 root root   264352 Oct 18 17:06 System.Private.Uri.dll
-rwxr-xr-x 1 root root   411808 Oct 18 17:06 System.Private.Xml.Linq.dll
-rwxr-xr-x 1 root root  8435872 Oct 18 17:06 System.Private.Xml.dll
-rwxr-xr-x 1 root root    75936 Oct 18 17:06 System.Reflection.DispatchProxy.dll
-rwxr-xr-x 1 root root    16032 Oct 18 16:21 System.Reflection.Emit.ILGeneration.dll
-rwxr-xr-x 1 root root    16032 Oct 18 16:21 System.Reflection.Emit.Lightweight.dll
-rwxr-xr-x 1 root root    16032 Oct 18 16:21 System.Reflection.Emit.dll
-rwxr-xr-x 1 root root    15488 Oct 18 16:21 System.Reflection.Extensions.dll
-rwxr-xr-x 1 root root  1149072 Oct 18 17:06 System.Reflection.Metadata.dll
-rwxr-xr-x 1 root root    16040 Oct 18 16:21 System.Reflection.Primitives.dll
-rwxr-xr-x 1 root root    43152 Oct 18 17:06 System.Reflection.TypeExtensions.dll
-rwxr-xr-x 1 root root    16528 Oct 18 16:21 System.Reflection.dll
-rwxr-xr-x 1 root root   129152 Oct 19 14:40 System.Resources.Extensions.dll
-rwxr-xr-x 1 root root    15520 Oct 18 16:21 System.Resources.Reader.dll
-rwxr-xr-x 1 root root    16000 Oct 18 16:21 System.Resources.ResourceManager.dll
-rwxr-xr-x 1 root root    55472 Oct 18 17:06 System.Resources.Writer.dll
-rwxr-xr-x 1 root root    16048 Oct 18 16:21 System.Runtime.CompilerServices.Unsafe.dll
-rwxr-xr-x 1 root root    34952 Oct 18 17:06 System.Runtime.CompilerServices.VisualC.dll
-rwxr-xr-x 1 root root    18080 Oct 18 16:21 System.Runtime.Extensions.dll
-rwxr-xr-x 1 root root    16000 Oct 18 16:21 System.Runtime.Handles.dll
-rwxr-xr-x 1 root root    51328 Oct 18 17:06 System.Runtime.InteropServices.JavaScript.dll
-rwxr-xr-x 1 root root    16000 Oct 18 16:21 System.Runtime.InteropServices.RuntimeInformation.dll
-rwxr-xr-x 1 root root    63656 Oct 18 17:06 System.Runtime.InteropServices.dll
-rwxr-xr-x 1 root root    17016 Oct 18 16:21 System.Runtime.Intrinsics.dll
-rwxr-xr-x 1 root root    16032 Oct 18 16:21 System.Runtime.Loader.dll
-rwxr-xr-x 1 root root   333960 Oct 18 17:06 System.Runtime.Numerics.dll
-rwxr-xr-x 1 root root   329888 Oct 18 17:06 System.Runtime.Serialization.Formatters.dll
-rwxr-xr-x 1 root root    16032 Oct 18 16:21 System.Runtime.Serialization.Json.dll
-rwxr-xr-x 1 root root    43168 Oct 18 17:07 System.Runtime.Serialization.Primitives.dll
-rwxr-xr-x 1 root root    17024 Oct 18 16:21 System.Runtime.Serialization.Xml.dll
-rwxr-xr-x 1 root root    17576 Oct 18 16:21 System.Runtime.Serialization.dll
-rwxr-xr-x 1 root root    43136 Oct 18 16:21 System.Runtime.dll
-rwxr-xr-x 1 root root   239776 Oct 18 17:07 System.Security.AccessControl.dll
-rwxr-xr-x 1 root root   100512 Oct 18 17:07 System.Security.Claims.dll
-rwxr-xr-x 1 root root    17536 Oct 18 16:21 System.Security.Cryptography.Algorithms.dll
-rwxr-xr-x 1 root root    16544 Oct 18 16:21 System.Security.Cryptography.Cng.dll
-rwxr-xr-x 1 root root    16504 Oct 18 16:21 System.Security.Cryptography.Csp.dll
-rwxr-xr-x 1 root root    15992 Oct 18 16:21 System.Security.Cryptography.Encoding.dll
-rwxr-xr-x 1 root root    15992 Oct 18 16:21 System.Security.Cryptography.OpenSsl.dll
-rwxr-xr-x 1 root root   870528 Oct 19 14:40 System.Security.Cryptography.Pkcs.dll
-rwxr-xr-x 1 root root    16000 Oct 18 16:21 System.Security.Cryptography.Primitives.dll
-rwxr-xr-x 1 root root    59528 Oct 19 14:40 System.Security.Cryptography.ProtectedData.dll
-rwxr-xr-x 1 root root    17568 Oct 18 16:21 System.Security.Cryptography.X509Certificates.dll
-rwxr-xr-x 1 root root   444576 Oct 19 14:40 System.Security.Cryptography.Xml.dll
-rwxr-xr-x 1 root root  1972368 Oct 18 17:07 System.Security.Cryptography.dll
-rwxr-xr-x 1 root root   186512 Oct 19 14:40 System.Security.Permissions.dll
-rwxr-xr-x 1 root root   190640 Oct 18 17:07 System.Security.Principal.Windows.dll
-rwxr-xr-x 1 root root    16032 Oct 18 16:21 System.Security.Principal.dll
-rwxr-xr-x 1 root root    15992 Oct 18 16:21 System.Security.SecureString.dll
-rwxr-xr-x 1 root root    19104 Oct 18 16:21 System.Security.dll
-rwxr-xr-x 1 root root    17552 Oct 18 16:21 System.ServiceModel.Web.dll
-rwxr-xr-x 1 root root    16512 Oct 18 16:21 System.ServiceProcess.dll
-rwxr-xr-x 1 root root   882864 Oct 18 17:07 System.Text.Encoding.CodePages.dll
-rwxr-xr-x 1 root root    16000 Oct 18 16:21 System.Text.Encoding.Extensions.dll
-rwxr-xr-x 1 root root    16000 Oct 18 16:21 System.Text.Encoding.dll
-rwxr-xr-x 1 root root   137384 Oct 18 17:07 System.Text.Encodings.Web.dll
-rwxr-xr-x 1 root root  1493136 Oct 18 17:07 System.Text.Json.dll
-rwxr-xr-x 1 root root   972944 Oct 18 17:07 System.Text.RegularExpressions.dll
-rwxr-xr-x 1 root root    96416 Oct 19 14:40 System.Threading.AccessControl.dll
-rwxr-xr-x 1 root root   137336 Oct 18 17:07 System.Threading.Channels.dll
-rwxr-xr-x 1 root root    16032 Oct 18 16:21 System.Threading.Overlapped.dll
-rwxr-xr-x 1 root root   530608 Oct 18 17:07 System.Threading.Tasks.Dataflow.dll
-rwxr-xr-x 1 root root    16504 Oct 18 16:21 System.Threading.Tasks.Extensions.dll
-rwxr-xr-x 1 root root   145584 Oct 18 17:07 System.Threading.Tasks.Parallel.dll
-rwxr-xr-x 1 root root    17016 Oct 18 16:21 System.Threading.Tasks.dll
-rwxr-xr-x 1 root root    16040 Oct 18 16:21 System.Threading.Thread.dll
-rwxr-xr-x 1 root root    16048 Oct 18 16:21 System.Threading.ThreadPool.dll
-rwxr-xr-x 1 root root    15480 Oct 18 16:21 System.Threading.Timer.dll
-rwxr-xr-x 1 root root    88224 Oct 18 17:07 System.Threading.dll
-rwxr-xr-x 1 root root   596128 Oct 18 17:08 System.Transactions.Local.dll
-rwxr-xr-x 1 root root    17536 Oct 18 16:21 System.Transactions.dll
-rwxr-xr-x 1 root root    16032 Oct 18 16:21 System.ValueTuple.dll
-rwxr-xr-x 1 root root    63632 Oct 18 17:08 System.Web.HttpUtility.dll
-rwxr-xr-x 1 root root    15992 Oct 18 16:21 System.Web.dll
-rwxr-xr-x 1 root root  1464456 Oct 19 14:40 System.Windows.Controls.Ribbon.dll
-rwxr-xr-x 1 root root   112784 Oct 19 14:40 System.Windows.Extensions.dll
-rwxr-xr-x 1 root root    16512 Oct 19 01:24 System.Windows.Forms.Design.Editors.dll
-rwxr-xr-x 1 root root  5335168 Oct 19 14:40 System.Windows.Forms.Design.dll
-rwxr-xr-x 1 root root   960672 Oct 19 14:40 System.Windows.Forms.Primitives.dll
-rwxr-xr-x 1 root root 13342848 Oct 19 14:40 System.Windows.Forms.dll
-rwxr-xr-x 1 root root   137352 Oct 19 14:40 System.Windows.Input.Manipulations.dll
-rwxr-xr-x 1 root root    30880 Oct 19 14:40 System.Windows.Presentation.dll
-rwxr-xr-x 1 root root    16544 Oct 18 16:21 System.Windows.dll
-rwxr-xr-x 1 root root  1439872 Oct 19 14:41 System.Xaml.dll
-rwxr-xr-x 1 root root    16552 Oct 18 16:21 System.Xml.Linq.dll
-rwxr-xr-x 1 root root    22144 Oct 18 16:21 System.Xml.ReaderWriter.dll
-rwxr-xr-x 1 root root    17040 Oct 18 16:21 System.Xml.Serialization.dll
-rwxr-xr-x 1 root root    16000 Oct 18 16:21 System.Xml.XDocument.dll
-rwxr-xr-x 1 root root    30888 Oct 18 17:08 System.Xml.XPath.XDocument.dll
-rwxr-xr-x 1 root root    16000 Oct 18 16:21 System.Xml.XPath.dll
-rwxr-xr-x 1 root root    16504 Oct 18 16:21 System.Xml.XmlDocument.dll
-rwxr-xr-x 1 root root    18040 Oct 18 16:21 System.Xml.XmlSerializer.dll
-rwxr-xr-x 1 root root    24704 Oct 18 16:21 System.Xml.dll
-rwxr-xr-x 1 root root    50816 Oct 18 16:21 System.dll
-rwxr-xr-x 1 root root   415872 Oct 19 14:41 UIAutomationClient.dll
-rwxr-xr-x 1 root root   882848 Oct 19 14:41 UIAutomationClientSideProviders.dll
-rwxr-xr-x 1 root root    59520 Oct 19 14:41 UIAutomationProvider.dll
-rwxr-xr-x 1 root root   309424 Oct 19 14:41 UIAutomationTypes.dll
-rwxr-xr-x 1 root root  2275472 Oct 19 14:41 WindowsBase.dll
-rwxr-xr-x 1 root root   211072 Oct 19 14:41 WindowsFormsIntegration.dll
-rwxr-xr-x 1 root root    35857 Nov 10 17:53 WpfApp.deps.json
-rwxr-xr-x 1 root root     6656 Nov 10 17:48 WpfApp.dll
-rwxr-xr-x 1 root root   152064 Nov 10 17:48 WpfApp.exe
-rwxr-xr-x 1 root root    13808 Nov 10 17:48 WpfApp.pdb
-rwxr-xr-x 1 root root      260 Nov 10 17:53 WpfApp.runtimeconfig.json
-rwxr-xr-x 1 root root   309408 Oct 18 16:08 clretwrc.dll
-rwxr-xr-x 1 root root   662656 Oct 18 16:01 clrgc.dll
-rwxr-xr-x 1 root root  1532592 Oct 18 16:03 clrjit.dll
-rwxr-xr-x 1 root root  5103280 Oct 18 16:11 coreclr.dll
-rwxr-xr-x 1 root root    61160 Oct 18 16:08 createdump.exe
drwxrwxrwx 1 root root     8192 Nov 10 17:53 cs
drwxrwxrwx 1 root root     8192 Nov 10 17:53 de
drwxrwxrwx 1 root root     8192 Nov 10 17:53 es
drwxrwxrwx 1 root root     8192 Nov 10 17:53 fr
-rwxr-xr-x 1 root root   383648 Oct 18 16:53 hostfxr.dll
-rwxr-xr-x 1 root root   394880 Oct 18 16:54 hostpolicy.dll
drwxrwxrwx 1 root root     8192 Nov 10 17:53 it
drwxrwxrwx 1 root root     8192 Nov 10 17:53 ja
drwxrwxrwx 1 root root     8192 Nov 10 17:53 ko
-rwxr-xr-x 1 root root  1315248 Oct 18 16:23 mscordaccore.dll
-rwxr-xr-x 1 root root  1315248 Oct 18 16:23 mscordaccore_amd64_amd64_7.0.22.51805.dll
-rwxr-xr-x 1 root root  1247136 Oct 18 16:22 mscordbi.dll
-rwxr-xr-x 1 root root    58488 Oct 18 16:21 mscorlib.dll
-rwxr-xr-x 1 root root   136880 Oct 18 16:08 mscorrc.dll
-rwxr-xr-x 1 root root   534416 Oct 18 16:21 msquic.dll
-rwxr-xr-x 1 root root   100992 Oct 18 16:21 netstandard.dll
drwxrwxrwx 1 root root     8192 Nov 10 17:53 pl
drwxrwxrwx 1 root root     8192 Nov 10 17:53 pt-BR
drwxrwxrwx 1 root root     8192 Nov 10 17:53 ru
drwxrwxrwx 1 root root     8192 Nov 10 17:53 tr
-rwxr-xr-x 1 root root    99216 Sep 21 10:03 vcruntime140_cor3.dll
-rwxr-xr-x 1 root root  1958000 Oct 19 04:34 wpfgfx_cor3.dll
drwxrwxrwx 1 root root     8192 Nov 10 17:53 zh-Hans
drwxrwxrwx 1 root root     8192 Nov 10 17:53 zh-Hant

これで、WPF も Linux CI でビルド、成果物を配布して Windows で実行という当たり前の世界がやってきましたね。 何年も待ってあきらめてましたがついに来たようです。

まとめ

誰か Windows ARM 向けにビルドして実行できるか試してくれないかなぁ。

ちなみに、linux-x64 向けビルドは失敗しました。

$ dotnet publish -c Release -r linux-x64 --self-contained
Error: /usr/share/dotnet/sdk/7.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(448,5): error NETSDK1082: There was no runtime pack for Microsoft.WindowsDesktop.App.WPF available for the specified RuntimeIdentifier 'linux-x64'. [/home/runner/work/WpfAppLinuxBuild/WpfAppLinuxBuild/WpfApp/WpfApp.csproj]

  1. ちょっといじらないとだめそうかな、という気配もあるので、誰もやってない感がすごい。
  2. WPF ライブラリも同様の流れです。