1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windows App SDKをWPF等に入れた場合のランタイム配布について、ポイントを調べてまとめました

Last updated at Posted at 2025-03-27

概要

Windows App SDKをWPFなどに組み込んで従来通りのインストーラで配布しようとすると、ランタイムを配布する必要があります。これが意外と気をつけるべき点が多くて調べるのに手間取ったので、調べたことをまとめます。

最初に結論まとめ

VC++ランタイムと、Windows App SDKのランタイムが必要です。それぞれ次のURLからダウンロードできます。(2025/3/22時点)

Windows App SDKのランタイムについては、InstallerとRedistributableが有りますが、Installerの方をDLすればOKです。

インストールすると、次の4つがインストールされます。アンインストールする場合は4つとも消す必要がありそうです。

  1. MicrosoftCorporationII.WinAppRuntime.Main.1.6_6000.424.1611.0_x64__8wekyb3d8bbwe
  2. MicrosoftCorporationII.WinAppRuntime.Singleton_6000.424.1611.0_x64__8wekyb3d8bbwe
  3. Microsoft.WinAppRuntime.DDLM.6000.424.1611.0-x6_6000.424.1611.0_x64__8wekyb3d8bbwe
  4. Microsoft.WinAppRuntime.DDLM.6000.424.1611.0-x8_6000.424.1611.0_x86__8wekyb3d8bbwe

詳しく説明

この記事が気になった人は、たぶんWindows App SDKの事は知っているのではないかと思います。Windowsの最新機能をアプリへ取り込めるSDKです。Win UI 3の前提として知っている人が多いのではと思いますが、Win UI 3ではなくてもWPF等でも使える機能がいくつもあります。例えばこの記事など。

これをWPF等に組み込んで従来のインストーラ等で配布する場合は、実行環境へランタイムを別途入れる必要があります。このやり方、つまり「パッケージ化されていないアプリ」のランタイム配布方法のポイントをこの記事でまとめます。(MSIXでパッケージ化する場合はまた別のようですが、それはここでは扱いません)

ポイント1,VCランタイムが必要

まず、VC++のランタイムが必要です。C#でWindows App SDKを使うだけであっても、VC++のランタイムが必要です。これはWindows App SDKのランタイム配布ページには書かれていないので、見落としがちです。

この情報は、こちらのページの下のほうの「その他の要件」にちょこっと書いてあります。

Windows アプリ SDKデプロイのアーキテクチャと概要 - Windows apps | Microsoft Learn
https://learn.microsoft.com/ja-jp/windows/apps/windows-app-sdk/deployment-architecture?utm_source=chatgpt.com

パッケージ化されていないアプリの場合は、Visual C++ 再頒布可能パッケージが必要です。 詳しくは、「Microsoft Visual C++ 再頒布可能パッケージの最新のサポートされているダウンロード」をご覧ください。

ポイント2,InstallerとRedistributableはどっちでもOK

Windows App SDKのランタイムは、配布サイトからダウンロードします。

Latest downloads for the Windows App SDK - Windows apps | Microsoft Learn
https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads

まず、並んでいるこの選択肢が謎です。

  • Installer (x64)
  • Installer (x86)
  • Installer (arm64)
  • Redistributable

InstallerとRedistributableということは、実行環境へ配布するランタイムはRedistributableでしょうか?と思ったら・・・

実は、InstallerでOKです。必要な物を選ぶことになりますが、いまだと多くの案件ではx64ですかね。

名前からすると、Redistributableが再頒布用に見えるんですが、実は中身は同じでした。Redistributableの方はzipファイルとなっていて、250MBほどあります。zipファイルの中を見ると、x64,x86,arm64,MSIXに分かれています。x64フォルダの中を見るとexeファイルが入っていて、Installerのリンクのexeファイルと同じものでした。どうやらRedistributableというのは、色々な環境に配布できるように全てのインストーラをzipファイルにまとめたもの、という意味だったようです。

ポイント3 インストーラはコンソールアプリ

さて、このexeファイル(WindowsAppRuntimeInstall-x64.exe)は何でしょうか。実行するとコンソールが開き、次のような標準出力が出ます。

Installing license: MSIX_MAINPACKAGE_LICENSE
Install License result : 0x0
Installing license: MSIX_SINGLETONPACKAGE_LICENSE
Install License result : 0x0
Deploying package: MicrosoftCorporationII.WinAppRuntime.Main.1.6_6000.424.1611.0_x64__8wekyb3d8bbwe
Package deployment result : 0x0
Provisioning result : 0x0
Deploying package: MicrosoftCorporationII.WinAppRuntime.Singleton_6000.424.1611.0_x64__8wekyb3d8bbwe
Package deployment result : 0x0
Provisioning result : 0x0
Deploying package: Microsoft.WinAppRuntime.DDLM.6000.424.1611.0-x6_6000.424.1611.0_x64__8wekyb3d8bbwe
Package deployment result : 0x0
Provisioning result : 0x0
Deploying package: Microsoft.WinAppRuntime.DDLM.6000.424.1611.0-x8_6000.424.1611.0_x86__8wekyb3d8bbwe
Package deployment result : 0x0
Provisioning result : 0x0
All install operations successful.

コンソールアプリでした。まあ必要十分という感じですが、IT慣れしていないユーザーに単体で配布するには抵抗があるかもしれません。

では、インストーラに組み込めるでしょうか。コマンドオプションを調べてみます。Webページには見当たりませんでしたが、ちゃんと-?オプションがありました。


WindowsAppRuntimeInstall-x64.exe -?
WindowsAppRuntimeInstaller -- Installs the Microsoft Windows App SDK runtimeversion: 1.6.0
Copyright(c) Microsoft Corporation. All rights reserved.

Options: (append - to disable e.g. --license- to not install licenses)
  --dry-run    Dry run (report but don't execute install operations)
  --license    Install licenses for WindowsAppSDK MSIX packages
  --msix       Install WindowsAppSDK MSIX packages. Cannot be used in combination with -r or --repair option
  -q, --quiet  Perform no user interaction and suppress all text output
  -f, --force  Force shutdown WindowsAppSDK's processes if necessary to update WinAppSDK's MSIX packages
  -r, --repair Repair WindowsAppSDK.Cannot be used in combination with --msix option
  -?, --help   Show help information
  --info       Display general information and disclosures of the installer

Consult the Windows App SDK documentation for additional guidance on installation and command line syntax.
Documentation URI: https://aka.ms/windowsappsdkinstall

コマンドオプションは充実していますね。既存のインストーラ等から呼び出すには十分な感じです。

アプリケーション終了コードとしては、成功時には0、誤ったオプションを打った時には-2147024736が返ってきています。ちゃんと判定できそうです。

管理やアンインストールはどうでしょうか。Windowsのアプリ画面を見ると、どうやら次の4つに分かれているようです。コンソールアプリの表示と同じですね。

image.png

image2.png

確かによく見ると配布ページに「App SDK Runtime which includes the Framework, Main, Singleton and DDLM packages.」と書いてあるので、どうやら4つで一つのようです。少し面倒ですが、4つまとめて管理するしかなさそうです。

これだけ情報が揃えば、配布の計画はできそうです。

まとめ

実行環境で使うためのランタイム配布ということで、1行で終わるような話かと思っていましたが・・・記事が一つ書けるくらいのポイントがありました。便利なので出来るところでは実運用に投入していきたいところですが、この辺りに気をつけて導入の計画を立てると良いと思います。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?