mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-02-06 11:22:04 +00:00
* fix(cli): improve Android BuildTask.kt Windows executable detection - Fix Android build error on Windows when using nvm4w - Add robust fallback logic for Windows executable detection - Prevent 'node.exe.cmd' and 'Cannot find module' errors - Graceful fallback to cargo when Node.js detection fails Fixes #13892 * strip extension from project, try exe/cmd/bat * revert args --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app>
This commit is contained in:
parent
3d6868d09c
commit
19fb6f7cb0
6
.changes/android-init-windows-unix.md
Normal file
6
.changes/android-init-windows-unix.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
'tauri-cli': 'patch:bug'
|
||||
'@tauri-apps/cli': patch:bug
|
||||
---
|
||||
|
||||
Strip Windows-only extensions from the binary path so an Android project initialized on Windows can be used on UNIX systems.
|
||||
6
.changes/fix-android-build-nvm4w-windows.md
Normal file
6
.changes/fix-android-build-nvm4w-windows.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
'tauri-cli': 'patch:bug'
|
||||
'@tauri-apps/cli': patch:bug
|
||||
---
|
||||
|
||||
Enhance Android build script usage on Windows by attempting to run cmd, bat and exe formats.
|
||||
@ -117,7 +117,16 @@ pub fn exec(
|
||||
build_args.push(target.command_name());
|
||||
build_args.push(target.ide_build_script_name());
|
||||
|
||||
map.insert("tauri-binary", binary.to_string_lossy());
|
||||
let mut binary = binary.to_string_lossy().to_string();
|
||||
if binary.ends_with(".exe") || binary.ends_with(".cmd") || binary.ends_with(".bat") {
|
||||
// remove Windows-only extension
|
||||
binary.pop();
|
||||
binary.pop();
|
||||
binary.pop();
|
||||
binary.pop();
|
||||
}
|
||||
|
||||
map.insert("tauri-binary", binary);
|
||||
map.insert("tauri-binary-args", &build_args);
|
||||
map.insert("tauri-binary-args-str", build_args.join(" "));
|
||||
|
||||
|
||||
@ -21,7 +21,23 @@ open class BuildTask : DefaultTask() {
|
||||
runTauriCli(executable)
|
||||
} catch (e: Exception) {
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
runTauriCli("$executable.cmd")
|
||||
// Try different Windows-specific extensions
|
||||
val fallbacks = listOf(
|
||||
"$executable.exe",
|
||||
"$executable.cmd",
|
||||
"$executable.bat",
|
||||
)
|
||||
|
||||
var lastException: Exception = e
|
||||
for (fallback in fallbacks) {
|
||||
try {
|
||||
runTauriCli(fallback)
|
||||
return
|
||||
} catch (fallbackException: Exception) {
|
||||
lastException = fallbackException
|
||||
}
|
||||
}
|
||||
throw lastException
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user