背景
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.exe は NestedInstallerFiles に登録しない(symlink を作らない)。
検討課題
関連
背景
winget の portable (zip) インストーラーは
PortableCommandAliasとして symlink を作成するが、.NET self-contained アプリの apphost は symlink の場所を基準に DLL を探すため、ターミナルからxtimelineviewerと直接打っても起動しない。提案
小さなネイティブ Win32 exe(
xtv.exe)を ZIP に同梱し、winget エイリアスはこちらに設定する。構成
launcher の実装イメージ(C)
winget マニフェスト
本体の
XTimelineViewer.exeはNestedInstallerFilesに登録しない(symlink を作らない)。検討課題
xtv.exeのビルドチェーン — C/C++ (MSVC) を CI に組み込むか、リポジトリにバイナリをコミットするかNestedInstallerFilesを上書きしないか確認関連