@@ -970,11 +970,7 @@ impl AppSettings for RustAppSettings {
970970 } )
971971 . unwrap_or_default ( ) ;
972972
973- if !binaries_paths
974- . iter ( )
975- . any ( |( _name, path) | path == Path :: new ( "src/main.rs" ) )
976- && tauri_dir. join ( "src/main.rs" ) . exists ( )
977- {
973+ if tauri_dir. join ( "src/main.rs" ) . exists ( ) {
978974 binaries_paths. push ( (
979975 self . cargo_package_settings . name . clone ( ) ,
980976 tauri_dir. join ( "src/main.rs" ) ,
@@ -984,7 +980,10 @@ impl AppSettings for RustAppSettings {
984980 for ( name, path) in binaries_paths {
985981 // see https://github.com/tauri-apps/tauri/pull/10977#discussion_r1759742414
986982 let bin_exists = binaries. iter ( ) . any ( |bin| {
987- bin. name ( ) == name || path. ends_with ( bin. src_path ( ) . map ( String :: as_str) . unwrap_or_default ( ) )
983+ bin. name ( ) == name
984+ || bin
985+ . src_path ( )
986+ . is_some_and ( |src_path| path. ends_with ( src_path) )
988987 } ) ;
989988 let bin_disabled = disabled_bins
990989 . iter ( )
@@ -1843,6 +1842,31 @@ mod tests {
18431842 assert ! ( binaries. iter( ) . any( |bin| bin. name( ) == "generate-bindings" ) ) ;
18441843 }
18451844
1845+ #[ test]
1846+ fn get_binaries_keeps_src_bin_when_bin_has_no_path ( ) {
1847+ let cargo_toml = r#"
1848+ [package]
1849+ name = "app"
1850+ version = "0.1.0"
1851+ default-run = "app"
1852+
1853+ [[bin]]
1854+ name = "other"
1855+ "# ;
1856+
1857+ let ( temp_dir, app_settings) = app_settings_with_manifest ( cargo_toml) ;
1858+ let tauri_dir = temp_dir. path ( ) ;
1859+
1860+ let binaries = app_settings
1861+ . get_binaries ( & Options :: default ( ) , tauri_dir)
1862+ . unwrap ( ) ;
1863+ let names = binaries. iter ( ) . map ( |bin| bin. name ( ) ) . collect :: < Vec < _ > > ( ) ;
1864+ assert ! ( names. contains( & "other" ) , "{names:?}" ) ;
1865+ assert ! ( names. contains( & "app" ) , "{names:?}" ) ;
1866+ assert ! ( names. contains( & "generate-bindings" ) , "{names:?}" ) ;
1867+ assert_eq ! ( names. len( ) , 3 , "{names:?}" ) ;
1868+ }
1869+
18461870 #[ test]
18471871 fn parse_profile_from_opts ( ) {
18481872 let options = Options {
0 commit comments