Skip to content

fix: copy WebView2Loader.dll beside the kept GNU Windows binary - #1403

Merged
tw93 merged 1 commit into
tw93:mainfrom
BenzidaneMo:fix/windows-gnu-keep-binary-webview2-loader
Oct 4, 2026
Merged

tw93 merged 1 commit into
tw93:mainfrom
BenzidaneMo:fix/windows-gnu-keep-binary-webview2-loader

Conversation

@BenzidaneMo

Copy link
Copy Markdown
Contributor

Related: #1402

Cause

With --windows-toolchain gnu, webview2-com-sys (0.38.2) can't link WebView2LoaderStatic the way it does on MSVC. It links the WebView2Loader.dll import library instead, so a GNU-built exe needs that DLL at runtime. tauri-build (2.5.5, target_env == "gnu" branch) copies the DLL into target/x86_64-pc-windows-gnu/<profile>/, and Tauri's MSI bundler includes it, so the MSI works. copyRawBinary() only copies pake-<name>.exe → <name>.exe, though, so the --keep-binary output doesn't start. Git Bash names api-ms-win-core-winrt-l1-1-0.dll as the missing library, which is misleading. objdump -p shows that WebView2Loader.dll is the only non-system import.

Change

  • WinBuilder overrides copyRawBinary. With the gnu toolchain, it also copies WebView2Loader.dll from the raw binary's build directory next to the output .exe. If the DLL is missing, it warns and doesn't fail the build.
  • WinBuilder overrides copyBuildArtifacts to record the DLL as a dll artifact (listed after the binary in --json outputs) and to log ✔ WebView2Loader.dll copied beside it — keep them together after "Raw binary located in".
  • MSVC builds and the MSI path are unchanged, and BaseBuilder is not touched.
  • Docs: --windows-toolchain and --keep-binary notes in cli-usage.md / cli-usage_CN.md.
  • dist/cli.js rebuilt.

Testing

  • Unit tests (tests/unit/windows-toolchain.test.ts, using temp dirs):

    • gnu copies the DLL;
    • msvc doesn't;
    • a missing DLL warns and doesn't throw;
    • copyBuildArtifacts with keepBinary records msi → binary → dll.

    The three GNU cases fail without the fix. npx vitest run: 498 passed, 3 skipped. pnpm run cli:build is clean.

  • Real build: Windows 11, rustc stable-x86_64-pc-windows-gnu, MSYS2 UCRT64 gcc on PATH.

    • node dist/cli.js https://example.com --name GnuTest --windows-toolchain gnu --keep-binary produces GnuTest.msi, GnuTest.exe and WebView2Loader.dll, with the new log line.
    • GnuTest.exe starts and opens its window.
    • With the DLL moved away, it fails with the original api-ms-win-core-winrt-l1-1-0.dll error (exit 127).
  • objdump -p GnuTest.exe: WebView2Loader.dll is the only non-system import.

  • --json: outputs lists msi, binary and dll with sizes.

  • MSVC: not built locally (no Build Tools on this machine). The msvc path is covered by the unit test, and it takes no new branch in the code.

With --windows-toolchain gnu, webview2-com-sys links the WebView2Loader.dll
import library instead of WebView2LoaderStatic, so the exe needs the DLL at
runtime. tauri-build places it beside the binary and the MSI bundles it, but
--keep-binary copied only the exe, which then failed to start.

WinBuilder now copies the DLL next to the kept exe on gnu, records it as a
dll artifact for --json, and logs it. MSVC builds are unchanged.

tw93#1402
@tw93

tw93 commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

@BenzidaneMo Thanks for the focused fix. It is merged and shipped in pake-cli 3.17.3: --windows-toolchain gnu --keep-binary now puts WebView2Loader.dll next to the kept executable, and MSVC and MSI builds are unchanged.

Run npm install -g pake-cli@3.17.3 and rebuild to get it.

@tw93
tw93 merged commit 3e906e8 into tw93:main Oct 4, 2026
8 checks passed
@BenzidaneMo
BenzidaneMo deleted the fix/windows-gnu-keep-binary-webview2-loader branch October 5, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants