@@ -15,7 +15,7 @@ use anyhow::Context;
1515use heck:: KebabCase ;
1616use serde:: Deserialize ;
1717
18- use crate :: helpers:: { app_paths:: tauri_dir, config:: Config , manifest:: Manifest } ;
18+ use crate :: helpers:: { app_paths:: tauri_dir, config:: Config , manifest:: Manifest , Logger } ;
1919use tauri_bundler:: {
2020 AppCategory , BundleBinary , BundleSettings , DebianSettings , MacOsSettings , PackageSettings ,
2121 UpdaterSettings , WindowsSettings , WixSettings ,
@@ -38,11 +38,11 @@ struct BinarySettings {
3838#[ derive( Debug , Clone , Deserialize ) ]
3939pub struct CargoPackageSettings {
4040 /// the package's name.
41- pub name : String ,
41+ pub name : Option < String > ,
4242 /// the package's version.
43- pub version : String ,
43+ pub version : Option < String > ,
4444 /// the package's description.
45- pub description : String ,
45+ pub description : Option < String > ,
4646 /// the package's homepage.
4747 pub homepage : Option < String > ,
4848 /// the package's authors.
@@ -148,17 +148,22 @@ impl AppSettings {
148148 } ;
149149
150150 let package_settings = PackageSettings {
151- product_name : config
152- . package
153- . product_name
154- . clone ( )
155- . unwrap_or_else ( || cargo_package_settings. name . clone ( ) ) ,
156- version : config
157- . package
158- . version
151+ product_name : config. package . product_name . clone ( ) . unwrap_or_else ( || {
152+ cargo_package_settings
153+ . name
154+ . clone ( )
155+ . expect ( "Cargo manifest must have the `package.name` field" )
156+ } ) ,
157+ version : config. package . version . clone ( ) . unwrap_or_else ( || {
158+ cargo_package_settings
159+ . version
160+ . clone ( )
161+ . expect ( "Cargo manifest must have the `package.version` field" )
162+ } ) ,
163+ description : cargo_package_settings
164+ . description
159165 . clone ( )
160- . unwrap_or_else ( || cargo_package_settings. version . clone ( ) ) ,
161- description : cargo_package_settings. description . clone ( ) ,
166+ . unwrap_or_default ( ) ,
162167 homepage : cargo_package_settings. homepage . clone ( ) ,
163168 authors : cargo_package_settings. authors . clone ( ) ,
164169 default_run : cargo_package_settings. default_run . clone ( ) ,
@@ -208,7 +213,7 @@ impl AppSettings {
208213 . unwrap_or_else ( || "" . to_string ( ) ) ;
209214 for binary in bin {
210215 binaries. push (
211- if binary. name . as_str ( ) == self . cargo_package_settings . name
216+ if Some ( & binary. name ) == self . cargo_package_settings . name . as_ref ( )
212217 || binary. name . as_str ( ) == default_run
213218 {
214219 BundleBinary :: new (
@@ -333,18 +338,33 @@ fn get_target_dir(
333338pub fn get_workspace_dir ( current_dir : & Path ) -> PathBuf {
334339 let mut dir = current_dir. to_path_buf ( ) ;
335340 let project_path = dir. clone ( ) ;
341+ let logger = Logger :: new ( "tauri:rust" ) ;
336342
337343 while dir. pop ( ) {
338- if let Ok ( cargo_settings) = CargoSettings :: load ( & dir) {
339- if let Some ( workspace_settings) = cargo_settings. workspace {
340- if let Some ( members) = workspace_settings. members {
341- if members
342- . iter ( )
343- . any ( |member| dir. join ( member) == project_path)
344- {
345- return dir;
344+ if dir. join ( "Cargo.toml" ) . exists ( ) {
345+ match CargoSettings :: load ( & dir) {
346+ Ok ( cargo_settings) => {
347+ if let Some ( workspace_settings) = cargo_settings. workspace {
348+ if let Some ( members) = workspace_settings. members {
349+ if members. iter ( ) . any ( |member| {
350+ glob:: glob ( & dir. join ( member) . to_string_lossy ( ) . into_owned ( ) )
351+ . unwrap ( )
352+ . any ( |p| p. unwrap ( ) == project_path)
353+ } ) {
354+ return dir;
355+ }
356+ }
346357 }
347358 }
359+ Err ( e) => {
360+ logger. warn ( format ! (
361+ "Found `{}`, which may define a parent workspace, but \
362+ failed to parse it. If this is indeed a parent workspace, undefined behavior may occur: \
363+ \n {:#}",
364+ dir. display( ) ,
365+ e
366+ ) ) ;
367+ }
348368 }
349369 }
350370 }
0 commit comments