Skip to content

feat(cli): add --no-binary-patching flag to build and bundle - #15619

Merged
Legend-Master merged 7 commits into
tauri-apps:devfrom
tenderdeve:feat/15591-disable-binary-patching
Jul 21, 2026
Merged

feat(cli): add --no-binary-patching flag to build and bundle#15619
Legend-Master merged 7 commits into
tauri-apps:devfrom
tenderdeve:feat/15591-disable-binary-patching

Conversation

@tenderdeve

Copy link
Copy Markdown
Contributor

Closes #15591.

Tauri patches the main executable with bundle type information (Patching app.exe with bundle type information: nsis) so the updater plugin can pick the matching installer format when several bundle types target the same platform. This rewrites the binary after it is built, invalidating an existing code signature on it — which makes bundling an already-signed binary inside e.g. the NSIS bundler impossible.

Change

Add a bundle > disableBinaryPatching config option (default false, so patching stays on). When set to true, bundle_project skips the patch_binary call and the post-patch re-sign, leaving the main binary untouched.

I gated the re-sign together with the patch because that re-sign exists only to repair the signature the patch invalidates (the main binary is intentionally skipped by sign_binaries_if_needed). So with patching disabled the executable is left exactly as built, preserving any existing signature — which is the point of the flag.

As @Legend-Master noted in the issue, the patching is only needed when shipping multiple installer types per platform that should each update with their own format, so disabling it is safe otherwise.

Files

  • tauri-utils: new disableBinaryPatching field on BundleConfig (+ ToTokens, regenerated config.schema.json)
  • tauri-bundler: disable_binary_patching on BundleSettings + Settings::disable_binary_patching(); guard in bundle_project
  • tauri-cli: map the config field into BundleSettings

Open question

I went with a config value (matches the rest of bundle). Happy to also add a --no-sign-style --disable-binary-patching CLI flag on tauri build/tauri bundle if you would prefer that too.

@tenderdeve
tenderdeve requested a review from a team as a code owner June 30, 2026 12:37
@Legend-Master Legend-Master added this to the 2.12 milestone Jul 2, 2026
@Legend-Master

Copy link
Copy Markdown
Contributor

let's go with --no-binary-patching

@tenderdeve tenderdeve changed the title feat(bundler): add bundle > disableBinaryPatching option feat(cli): add --no-binary-patching flag to build and bundle Jul 2, 2026
@tenderdeve

Copy link
Copy Markdown
Contributor Author

@Legend-Master switched to --no-binary-patching as agreed — dropped the bundle > disableBinaryPatching config option and the tauri-utils change entirely. It's now a CLI flag on both tauri build and tauri bundle, wired through Settings::set_no_binary_patching exactly like --no-sign. When set, the bundler skips the patch_binary call and the post-patch re-sign, leaving an already-signed binary untouched.

Pushed in 8d3139d. Rebuilt fmt/clippy clean on tauri-bundler + tauri-cli (the one remaining clippy warning is pre-existing in pbxproj.rs, unrelated).

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Package Changes Through 3553abb

There are 14 changes which include tauri with minor, tauri-cli with minor, @tauri-apps/cli with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri-bundler with minor, tauri-build with minor, tauri-macos-sign with minor, tauri-codegen with minor, tauri-macros with minor, tauri-plugin with minor, tauri-driver with minor, @tauri-apps/api with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.11.1 2.12.0
tauri-utils 2.9.3 2.10.0
tauri-macos-sign 2.3.4 2.4.0
tauri-bundler 2.9.4 2.10.0
tauri-runtime 2.11.3 2.12.0
tauri-runtime-wry 2.11.4 2.12.0
tauri-codegen 2.6.3 2.7.0
tauri-macros 2.6.3 2.7.0
tauri-plugin 2.6.3 2.7.0
tauri-build 2.6.3 2.7.0
tauri 2.11.5 2.12.0
@tauri-apps/cli 2.11.4 2.12.0
tauri-cli 2.11.4 2.12.0
tauri-driver 2.0.6 2.1.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Legend-Master Legend-Master left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just some small nitpicks

Also you'll need to sign your commits for me to merge this

https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

@@ -0,0 +1,6 @@
---
"tauri-bundler": "minor:feat"
"tauri-cli": "minor:feat"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"tauri-cli": "minor:feat"
"tauri-cli": "minor:feat"
"@tauri-apps/cli": "minor:feat"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied — the changefile now lists all three (tauri-bundler, tauri-cli, @tauri-apps/cli) as minor:feat.


/// Sets whether to disable patching the main binary with bundle type information.
#[must_use]
pub fn no_binary_patching(mut self, no_binary_patching: bool) -> Self {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we had no_sign above, but generally speaking, we should use positive flags (e.g. binary_pacthing and true by default)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — flipped to a positive binary_patching flag defaulting to true (the CLI flag stays --no-binary-patching, which just sets it to false).

@tenderdeve
tenderdeve force-pushed the feat/15591-disable-binary-patching branch from 8d3139d to a22ac40 Compare July 9, 2026 07:29
@tenderdeve

Copy link
Copy Markdown
Contributor Author

@Legend-Master addressed both:

  • Settings now stores a positive binary_patching: bool defaulting to true (getter/setter/builder renamed to match). The --no-binary-patching CLI flag stays as agreed and just flips it off at the boundary via set_binary_patching(!options.no_binary_patching).
  • Added @tauri-apps/cli to the changefile.

Also signed all commits (Verified now). cargo check + fmt clean.

Default::default()
Self {
binary_patching: true,
..Default::default()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's manually implement the default instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a0e9f93fb — dropped #[derive(Default)] and hand-wrote impl Default for SettingsBuilder with binary_patching: true; new() is now just Self::default().

Comment thread crates/tauri-bundler/src/bundle.rs Outdated
Comment on lines +148 to +150
// Patching rewrites the main binary in place, invalidating any existing code signature.
// When disabled, leave the binary untouched and skip the post-patch re-sign (whose only
// purpose is to repair that invalidated signature), preserving an already-signed binary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Patching rewrites the main binary in place, invalidating any existing code signature.
// When disabled, leave the binary untouched and skip the post-patch re-sign (whose only
// purpose is to repair that invalidated signature), preserving an already-signed binary.

Remove this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

if matches!(target_os, TargetPlatform::Windows) && settings.windows().can_sign() {
windows::sign::try_sign(&main_binary_path, settings)?;
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a notice like we did for --no-sign

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added — logs Skipping binary patching due to --no-binary-patching flag. Put it once before the loop rather than in a per-package_type else so it does not repeat for each bundle; mirrors the single --no-sign notice.

@Legend-Master Legend-Master added the status: waiting Waiting on author label Jul 16, 2026
Tauri patches the main executable with bundle type information so the updater
plugin can pick the matching installer format when multiple bundle types target
the same platform. This rewrites the binary after it is built, invalidating an
existing code signature on it, which breaks bundling an already-signed binary
(e.g. inside the NSIS bundler).

Add a `bundle > disableBinaryPatching` config option (default false). When set,
the bundler skips patching the main binary and the subsequent re-sign, leaving
the executable untouched.

closes tauri-apps#15591
Switch the disable-binary-patching control from the proposed
`bundle > disableBinaryPatching` config option to a `--no-binary-patching`
CLI flag on `tauri build` and `tauri bundle`, mirroring the `--no-sign`
precedent. When set, the bundler skips patching the main executable with
bundle type information (and the subsequent re-sign), preserving an
already-signed binary. Patching only matters when shipping multiple bundle
types per platform.
- Implement Default for SettingsBuilder manually so binary_patching
  defaults to true, instead of overriding it on top of a derived default.
- Log a notice when --no-binary-patching skips patching, mirroring the
  --no-sign notice, and drop the now-redundant inline comment.
@tenderdeve
tenderdeve force-pushed the feat/15591-disable-binary-patching branch from 54f7e3d to a0e9f93 Compare July 20, 2026 11:00
@tenderdeve

Copy link
Copy Markdown
Contributor Author

@Legend-Master addressed all nitpicks in a0e9f93fb, and signed the whole branch — all five commits now show as Verified. Thanks for the review.

@Legend-Master Legend-Master removed the status: waiting Waiting on author label Jul 21, 2026

@Legend-Master Legend-Master left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@Legend-Master
Legend-Master merged commit af465ea into tauri-apps:dev Jul 21, 2026
20 checks passed
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.

[feat] add the option to disable binary patching on bundling

2 participants