From 21c0f4f2447e358c8b9481dd237532813324c526 Mon Sep 17 00:00:00 2001 From: Havunen Date: Wed, 11 Mar 2026 19:55:23 +0200 Subject: [PATCH] fix windows installer --- .github/workflows/build-release-artifacts.yml | 4 +- .gitignore | 1 + .../gitcomet-app/src/bin/gitcomet-launcher.rs | 33 ++++ crates/gitcomet-app/wix/main.wxs | 144 ++++++++++++++++++ dist/gitcomet.desktop | 9 -- scripts/test_windows_installer.cmd | 1 + 6 files changed, 181 insertions(+), 11 deletions(-) create mode 100644 crates/gitcomet-app/src/bin/gitcomet-launcher.rs create mode 100644 crates/gitcomet-app/wix/main.wxs delete mode 100644 dist/gitcomet.desktop create mode 100644 scripts/test_windows_installer.cmd diff --git a/.github/workflows/build-release-artifacts.yml b/.github/workflows/build-release-artifacts.yml index 28a78850..fcdf068b 100644 --- a/.github/workflows/build-release-artifacts.yml +++ b/.github/workflows/build-release-artifacts.yml @@ -122,7 +122,7 @@ jobs: - name: Build release binary shell: pwsh run: | - cargo build -p gitcomet-app --release --locked --features ui-gpui,gix + cargo build -p gitcomet-app --release --locked --features ui-gpui,gix --bins - name: Package portable ZIP shell: pwsh @@ -144,7 +144,7 @@ jobs: $ErrorActionPreference = "Stop" choco install wixtoolset --version "${env:WIXTOOLSET_VERSION}" --yes --no-progress cargo install cargo-wix --version "${env:CARGO_WIX_VERSION}" --locked - if (!(Test-Path "wix\main.wxs")) { + if (!(Test-Path "crates\gitcomet-app\wix\main.wxs")) { cargo wix init --package gitcomet-app } $msiName = "gitcomet-v${env:VERSION}-windows-x86_64.msi" diff --git a/.gitignore b/.gitignore index ab74d5c8..b6386547 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ local_*.sh tmp/* feat/* .autoresearch/* +dist/ diff --git a/crates/gitcomet-app/src/bin/gitcomet-launcher.rs b/crates/gitcomet-app/src/bin/gitcomet-launcher.rs new file mode 100644 index 00000000..5dd52552 --- /dev/null +++ b/crates/gitcomet-app/src/bin/gitcomet-launcher.rs @@ -0,0 +1,33 @@ +#![cfg_attr(target_os = "windows", windows_subsystem = "windows")] + +#[cfg(target_os = "windows")] +fn main() { + use std::env; + use std::os::windows::process::CommandExt; + use std::process::Command; + + // Prevent the console-subsystem app from creating a visible terminal window + // when launched from Start Menu shortcuts. + const CREATE_NO_WINDOW: u32 = 0x0800_0000; + + let Ok(current_exe) = env::current_exe() else { + return; + }; + let Some(install_dir) = current_exe.parent() else { + return; + }; + let app_exe = install_dir.join("gitcomet-app.exe"); + + let mut cmd = Command::new(app_exe); + cmd.current_dir(install_dir); + cmd.creation_flags(CREATE_NO_WINDOW); + cmd.args(env::args_os().skip(1)); + + let _ = cmd.spawn(); +} + +#[cfg(not(target_os = "windows"))] +fn main() { + eprintln!("gitcomet-launcher is only supported on Windows"); + std::process::exit(1); +} diff --git a/crates/gitcomet-app/wix/main.wxs b/crates/gitcomet-app/wix/main.wxs new file mode 100644 index 00000000..1e5f94c2 --- /dev/null +++ b/crates/gitcomet-app/wix/main.wxs @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 1 + + + + diff --git a/dist/gitcomet.desktop b/dist/gitcomet.desktop deleted file mode 100644 index 653d0124..00000000 --- a/dist/gitcomet.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Type=Application -Name=GitComet -Comment=GitComet - Git UI -Exec=gitcomet-app -Icon=gitcomet -StartupWMClass=gitcomet -Terminal=false -Categories=Development;RevisionControl; diff --git a/scripts/test_windows_installer.cmd b/scripts/test_windows_installer.cmd new file mode 100644 index 00000000..1bfd67e9 --- /dev/null +++ b/scripts/test_windows_installer.cmd @@ -0,0 +1 @@ +cargo wix crates\gitcomet-app\Cargo.toml -p gitcomet-app --profile release --nocapture --output dist\gitcomet-local-test.msi \ No newline at end of file