Skip to content

winget 向けに xtv launcher を導入してコマンドライン起動を可能にする #170

@daruyanagi

Description

@daruyanagi

背景

winget の portable (zip) インストーラーは PortableCommandAlias として symlink を作成するが、.NET self-contained アプリの apphost は symlink の場所を基準に DLL を探すため、ターミナルから xtimelineviewer と直接打っても起動しない。

> xtimelineviewer
The application to execute does not exist: '...\WinGet\Links\XTimelineViewer.dll'.

提案

小さなネイティブ Win32 exe(xtv.exe)を ZIP に同梱し、winget エイリアスはこちらに設定する。

構成

WinGet\Links\xtv.exe  (symlink)
    ↓
WinGet\Packages\...\xtv.exe  (ネイティブ launcher, 数 KB)
    ↓ ShellExecuteEx
WinGet\Packages\...\XTimelineViewer.exe  (本体)

launcher の実装イメージ(C)

#include <windows.h>

int WINAPI wWinMain(HINSTANCE h, HINSTANCE p, LPWSTR cmd, int show) {
    WCHAR me[MAX_PATH];
    GetModuleFileNameW(NULL, me, MAX_PATH);

    // symlink を解決して実体のディレクトリを取得
    HANDLE hFile = CreateFileW(me, 0, FILE_SHARE_READ, NULL,
                               OPEN_EXISTING, 0, NULL);
    WCHAR real[MAX_PATH];
    GetFinalPathNameByHandleW(hFile, real, MAX_PATH, 0);
    CloseHandle(hFile);

    // ファイル名を差し替え
    wchar_t *slash = wcsrchr(real, L'\');
    wcscpy(slash + 1, L"XTimelineViewer.exe");

    ShellExecuteW(NULL, NULL, real, NULL, NULL, SW_SHOWNORMAL);
    return 0;
}

winget マニフェスト

NestedInstallerFiles:
- RelativeFilePath: xtv.exe
  PortableCommandAlias: xtv

本体の XTimelineViewer.exeNestedInstallerFiles に登録しない(symlink を作らない)。

検討課題

  • xtv.exe のビルドチェーン — C/C++ (MSVC) を CI に組み込むか、リポジトリにバイナリをコミットするか
  • komac(winget マニフェスト自動生成)がカスタム NestedInstallerFiles を上書きしないか確認
  • arm64 対応 — launcher も arm64 版が必要か(ネイティブ exe なのでアーキテクチャ依存)
  • launcher のエラーハンドリング — 本体が見つからない場合のメッセージ表示

関連

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions