fix(cli): allow build --bundles nsis arg in linux+macOS#14954
fix(cli): allow build --bundles nsis arg in linux+macOS#14954FabianLars merged 8 commits intotauri-apps:devfrom
build --bundles nsis arg in linux+macOS#14954Conversation
|
thanks for the PR! nsis builds can be built on macOS as well so this needs a little bit more thinking. I'm only on my phone right now so can't help much but let me know if you need help and i'll get back to you when i can :) |
|
No worries, I can try setting up cross-compilation in macOS and update the PR |
|
@FabianLars was able to produce a working NSIS exe in macOS by just extending the cfg-guard in |
build --bundles nsis arg in linuxbuild --bundles nsis arg in linux+macOS
Package Changes Through e02c76aThere are 5 changes which include tauri-macos-sign with patch, tauri with minor, tauri-bundler with patch, tauri-cli with patch, @tauri-apps/cli with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
|
@FabianLars let me know if you need me to verify/test anything else or if this approach is sufficient for now, thanks! |
268ca4e to
413729e
Compare
413729e to
8e69607
Compare
| #[cfg(target_os = "windows")] | ||
| PackageType::WindowsMsi, | ||
| #[cfg(target_os = "windows")] | ||
| #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))] |
There was a problem hiding this comment.
| #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))] | |
| // NSIS installers can be built on all platforms but it's hidden in the --help output on macOS/Linux. |
mobile etc aren't a concern here so we can just remove the cfg, same as the Updater variant below
|
i cannot push to your branch, can you change line 46 in bundle.rs to this? let hide = (!cfg!(windows) && self.0 == PackageType::Nsis) || self.0 == PackageType::Updater;This should hide the nsis bundle from the help output on linux/macos cause it looks kinda weird imo and may be confusing to those not knowing that nsis is windows only |
|
Sorry for the super slow feedback loop! I don't have my mac machine with me to test but according to the code and the logs you shared the bundle_type is not patched into the binary which we need for proper updater support. If you want to take a look that'd be appreciated, otherwise i'll have my macbook again next week :) |
|
No worries, I'll try taking a look when I get a chance |
|
@FabianLars looks like the patching flow is being performed now with the latest changes: build output from macos host + cargo-xwin (without binary signing): for comparison, build output from linux host + cargo-xwin (with binary signing): |
| // NSIS installers can be built in macOS using cargo-xwin | ||
| crate::PackageType::Nsis => b"__TAURI_BUNDLE_TYPE_VAR_NSS", | ||
| _ => { | ||
| return Err(crate::Error::InvalidPackageType( |
There was a problem hiding this comment.
didn't test it but i think this will return an error when you're building for macos on macos now. I think we still should not patch these binaries but we could return Ok(()) in these cases. Just wondering if that should happen at the top of the function so we don't print the "Patchin x with bundle type information" stuff 🤔
There was a problem hiding this comment.
Oops yeah it emitted a warning about but still but continued with the rest of the bundling process since patching is best-effort:
if let Err(e) = patch_binary(&main_binary_path, package_type) {
log::warn!("Failed to add bundler type to the binary: {e}. Updater plugin may not be able to update this package. This shouldn't normally happen, please report it to https://github.com/tauri-apps/tauri/issues");
}I moved things around a bit, lmk what you think
macos native bundle:
Finished `release` profile [optimized] target(s) in 32.46s
Built application at: /Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/sentinowl
Bundling Sentinowl.app (/Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/macos/Sentinowl.app)
Signing with identity "M4DQ8GQP99"
Signing with identity "M4DQ8GQP99"
Signing /Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/macos/Sentinowl.app/Contents/MacOS/smartctl
/Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/macos/Sentinowl.app/Contents/MacOS/smartctl: replacing existing signature
Signing with identity "M4DQ8GQP99"
Signing /Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/macos/Sentinowl.app/Contents/MacOS/sentinowl
/Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/macos/Sentinowl.app/Contents/MacOS/sentinowl: replacing existing signature
Signing with identity "M4DQ8GQP99"
Signing /Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/macos/Sentinowl.app
/Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/macos/Sentinowl.app: replacing existing signature
Signing with identity "M4DQ8GQP99"
Signing /var/folders/dn/9c46q9997jq536qwbl3k67x40000gr/T/.tmpJn8d56/Sentinowl.zip
Notarizing /Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/macos/Sentinowl.app
Notarizing Finished with status Accepted for id 8c4b306d-5a9f-443b-964d-7f51dcfd00d2 (Processing complete)
Stapling app...
Bundling Sentinowl_0.10.1_aarch64.dmg (/Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/dmg/Sentinowl_0.10.1_aarch64.dmg)
Running bundle_dmg.sh
Signing with identity "M4DQ8GQP99"
Signing with identity "M4DQ8GQP99"
Signing /Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/dmg/Sentinowl_0.10.1_aarch64.dmg
Bundling /Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/macos/Sentinowl.app.tar.gz (/Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/macos/Sentinowl.app.tar.gz)
Finished 2 bundles at:
/Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/macos/Sentinowl.app
/Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/dmg/Sentinowl_0.10.1_aarch64.dmg
/Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/macos/Sentinowl.app.tar.gz (updater)
Finished 1 updater signature at:
/Users/sentinowl/src/sentinowl-desktop/core/target/aarch64-apple-darwin/release/bundle/macos/Sentinowl.app.tar.gz.sig
macos host + cargo-xwin:
Compiling sentinowl v0.10.1 (/Users/sentinowl/src/sentinowl-desktop/core)
Finished `release` profile [optimized] target(s) in 31.70s
Built application at: /Users/sentinowl/src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/sentinowl.exe
Warn Cross-platform compilation is experimental and does not support all features. Please use a matching host system for full compatibility.
Warn Signing, by default, is only supported on Windows hosts, but you can specify a custom signing command in `bundler > windows > sign_command`, for now, skipping signing the installer...
Info Patching /Users/sentinowl/src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/sentinowl.exe with bundle type information: nsis
Info Target: x64
Running makensis to produce /Users/sentinowl/src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/bundle/nsis/Sentinowl_0.10.1_x64-setup.exe
warning 5202: -OUTPUTCHARSET is disabled for non Win32 platforms.
Warn Signing, by default, is only supported on Windows hosts, but you can specify a custom signing command in `bundler > windows > sign_command`, for now, skipping signing the installer...
Finished 1 bundle at:
/Users/sentinowl/src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/bundle/nsis/Sentinowl_0.10.1_x64-setup.exe
Finished 1 updater signature at:
/Users/sentinowl/src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/bundle/nsis/Sentinowl_0.10.1_x64-setup.exe.sig
linux host + cargo-xin:
Compiling sentinowl v0.10.1 (/src/sentinowl-desktop/core)
Finished `release` profile [optimized] target(s) in 25.15s
Built application at: /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/sentinowl.exe
Warn Cross-platform compilation is experimental and does not support all features. Please use a matching host system for full compatibility.
Signing ../../build-artifacts/smartmontools/smartctl-x86_64-pc-windows-msvc.exe
Signing ../../build-artifacts/smartmontools/smartctl-x86_64-pc-windows-msvc.exe with a custom signing command
Signing Output of signing command:
skipping signing of smartctl binary [../../build-artifacts/smartmontools/smartctl-x86_64-pc-windows-msvc.exe]
Info Patching /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/sentinowl.exe with bundle type information: nsis
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/sentinowl.exe
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/sentinowl.exe with a custom signing command
Signing Output of signing command:
Adding Authenticode signature to /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/sentinowl.exe
Info Target: x64
Info Signing NSIS plugins
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/NSISdl.dll
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/NSISdl.dll with a custom signing command
Signing Output of signing command:
skipping signing of dll [/src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/NSISdl.dll]
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/StartMenu.dll
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/StartMenu.dll with a custom signing command
Signing Output of signing command:
skipping signing of dll [/src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/StartMenu.dll]
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/System.dll
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/System.dll with a custom signing command
Signing Output of signing command:
skipping signing of dll [/src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/System.dll]
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/nsDialogs.dll
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/nsDialogs.dll with a custom signing command
Signing Output of signing command:
skipping signing of dll [/src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/nsDialogs.dll]
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/additional/nsis_tauri_utils.dll
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/additional/nsis_tauri_utils.dll with a custom signing command
Signing Output of signing command:
skipping signing of dll [/src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/nsis/x64/Plugins/x86-unicode/additional/nsis_tauri_utils.dll]
Running makensis to produce /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/bundle/nsis/Sentinowl_0.10.1_x64-setup.exe
warning 5202: -OUTPUTCHARSET is disabled for non Win32 platforms.
Adding Authenticode signature to /tmp/makensisgFoE6r
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/bundle/nsis/Sentinowl_0.10.1_x64-setup.exe
Signing /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/bundle/nsis/Sentinowl_0.10.1_x64-setup.exe with a custom signing command
Signing Output of signing command:
Adding Authenticode signature to /src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/bundle/nsis/Sentinowl_0.10.1_x64-setup.exe
Finished 1 bundle at:
/src/sentinowl-desktop/core/target/x86_64-pc-windows-msvc/release/bundle/nsis/Sentinowl_0.10.1_x64-setup.exe
Finished 1 updater signature at:
/home/sam/var/cargo-build/sentinowl/x86_64-pc-windows-msvc/release/bundle/nsis/Sentinowl_0.10.1_x64-setup.exe.sig
crates/tauri-bundler/src/bundle.rs
Outdated
| // skip patching for macOS-native bundles | ||
| return Ok(()) |
There was a problem hiding this comment.
i'm okay with this but i think we should keep the _ => Error and only return Ok(()) for the MacOsBundle and Dmg PackageTypes. what do you think?
Co-authored-by: Fabian-Lars <30730186+FabianLars@users.noreply.github.com>
FabianLars
left a comment
There was a problem hiding this comment.
thanks for putting up with me :D
Allow
nsisvalue to be passed as arg tobuildsubcommand when cross-compiling windows binaries on linux hosts.This was discussed way back in #13943 but I hadn't gotten around to implementing it since omitting the
--bundlesflag when invokingpnpm tauri build --target x86_64-pc-windows-msvc --runner cargo-xwinwould just result in both MSI and NSIS bundles being produced (with MSI bundling being a no-op on linux hosts).This needs to be explicitly allowed now since #14521 gated the windows bundling logic behind
#[cfg(target_os = "windows")].