@@ -348,11 +348,12 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
348348 . window_icon_path
349349 . unwrap_or_else ( || find_icon ( & config, |i| i. ends_with ( ".ico" ) , "icons/icon.ico" ) ) ;
350350
351- if window_icon_path. exists ( ) {
352- let mut res = WindowsResource :: new ( ) ;
351+ if target_triple. contains ( "windows" ) {
352+ if window_icon_path. exists ( ) {
353+ let mut res = WindowsResource :: new ( ) ;
353354
354- res. set_manifest (
355- r#"
355+ res. set_manifest (
356+ r#"
356357 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
357358 <dependency>
358359 <dependentAssembly>
@@ -368,42 +369,43 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
368369 </dependency>
369370 </assembly>
370371 "# ,
371- ) ;
372-
373- if let Some ( sdk_dir) = & attributes. windows_attributes . sdk_dir {
374- if let Some ( sdk_dir_str) = sdk_dir. to_str ( ) {
375- res. set_toolkit_path ( sdk_dir_str) ;
376- } else {
377- return Err ( anyhow ! (
378- "sdk_dir path is not valid; only UTF-8 characters are allowed"
379- ) ) ;
372+ ) ;
373+
374+ if let Some ( sdk_dir) = & attributes. windows_attributes . sdk_dir {
375+ if let Some ( sdk_dir_str) = sdk_dir. to_str ( ) {
376+ res. set_toolkit_path ( sdk_dir_str) ;
377+ } else {
378+ return Err ( anyhow ! (
379+ "sdk_dir path is not valid; only UTF-8 characters are allowed"
380+ ) ) ;
381+ }
380382 }
381- }
382- if let Some ( version) = & config. package . version {
383- if let Ok ( v) = Version :: parse ( version) {
384- let version = v. major << 48 | v. minor << 32 | v. patch << 16 ;
385- res. set_version_info ( VersionInfo :: FILEVERSION , version) ;
386- res. set_version_info ( VersionInfo :: PRODUCTVERSION , version) ;
383+ if let Some ( version) = & config. package . version {
384+ if let Ok ( v) = Version :: parse ( version) {
385+ let version = v. major << 48 | v. minor << 32 | v. patch << 16 ;
386+ res. set_version_info ( VersionInfo :: FILEVERSION , version) ;
387+ res. set_version_info ( VersionInfo :: PRODUCTVERSION , version) ;
388+ }
389+ res. set ( "FileVersion" , version) ;
390+ res. set ( "ProductVersion" , version) ;
387391 }
388- res. set ( "FileVersion" , version) ;
389- res. set ( "ProductVersion" , version) ;
390- }
391- if let Some ( product_name) = & config. package . product_name {
392- res. set ( "ProductName" , product_name) ;
393- res. set ( "FileDescription" , product_name) ;
394- }
395- res. set_icon_with_id ( & window_icon_path. display ( ) . to_string ( ) , "32512" ) ;
396- res. compile ( ) . with_context ( || {
397- format ! (
398- "failed to compile `{}` into a Windows Resource file during tauri-build" ,
392+ if let Some ( product_name) = & config. package . product_name {
393+ res. set ( "ProductName" , product_name) ;
394+ res. set ( "FileDescription" , product_name) ;
395+ }
396+ res. set_icon_with_id ( & window_icon_path. display ( ) . to_string ( ) , "32512" ) ;
397+ res. compile ( ) . with_context ( || {
398+ format ! (
399+ "failed to compile `{}` into a Windows Resource file during tauri-build" ,
400+ window_icon_path. display( )
401+ )
402+ } ) ?;
403+ } else {
404+ return Err ( anyhow ! ( format!(
405+ "`{}` not found; required for generating a Windows Resource file during tauri-build" ,
399406 window_icon_path. display( )
400- )
401- } ) ?;
402- } else {
403- return Err ( anyhow ! ( format!(
404- "`{}` not found; required for generating a Windows Resource file during tauri-build" ,
405- window_icon_path. display( )
406- ) ) ) ;
407+ ) ) ) ;
408+ }
407409 }
408410
409411 let target_env = std:: env:: var ( "CARGO_CFG_TARGET_ENV" ) . unwrap ( ) ;
0 commit comments