electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.58k stars 1.73k forks source link

Windows icon path unquoted, leads to error #3889

Open jandrieu opened 5 years ago

jandrieu commented 5 years ago

In my windows configuration, I use the following:

    "win": {
      "target": "zip",
      "icon" : "logos/favicon/Favicon.ico"
    }  

And the release command:

"release": "npm test && npm run generate-license && webpack --config=build/webpack.app.config.js --env=production && electron-builder",

When I run "npm run release", I get an error because the windows file path is not quoted, so drive "C" is the attempted target for finding an icon:

  • electron-builder version=20.40.2
  • loaded configuration file=package.json ("build" field)
  • no native production dependencies
  • packaging       platform=win32 arch=x64 electron=2.0.2 appOutDir=dist\win-unpacked
Error: Exit code: 1. Command failed: C:\Users\Joe\AppData\Local\electron-builder\Cache\winCodeSign\winCodeSign-2.4.0\rcedit-ia32.exe C:\Users\Joe\Documents\Organizations\Satyrn\satyrn\dist\win-unpacked\Satyrn.exe --set-version-string FileDescription Satyrn --set-version-string ProductName Satyrn --set-version-string LegalCopyright Copyright © 2019 Joe Andrieu --set-file-version 0.0.0 --set-product-version 0.0.0.0 --set-version-string InternalName Satyrn --set-version-string OriginalFilename  --set-version-string CompanyName Joe Andrieu --set-icon C:\Users\Joe\Documents\Organizations\Satyrn\satyrn\logos\favicon\Favicon.ico
Reserved header is not 0 or image type is not icon for 'C'
Fatal error: Unable to set icon

Reserved header is not 0 or image type is not icon for 'C'
Fatal error: Unable to set icon

    at C:\Users\Joe\Documents\Organizations\Satyrn\satyrn\node_modules\builder-util\src\util.ts:126:16

[I snipped the rest of the trace]

Note: the constructed file path for the icon is correct. If it were just quoted, I believe this would work.

I looked through the source, but my initial inspection did not find the spot where the command is constructed.

Any pointers would be appreciated.

HarounAns commented 5 years ago

I'm also running into this problem, not sure if there are workarounds to set the application icon on windows or not

jandrieu commented 5 years ago

Someone who knows the code base should be able to update the open to use a well-structured path rather than just throw the string into the function. I'm just not sure where it is. We went ahead and shipped our MVP without an icon, but it's an issue we'd still like to see fixed.

develar commented 5 years ago

Please specify your windows version and arch (32 or 64 bit).

HarounAns commented 5 years ago

For me its 64bit Windows 10

jandrieu commented 5 years ago

Me too.

develar commented 5 years ago

it is not electron-builder issue. But it doesn't matter for you as end user. I am investigating why it is broken.

develar commented 5 years ago

Please try 21.0.11

wind-hx commented 4 years ago

Please try 21.0.11

image

zykoikaze commented 3 years ago

Has this problem been solved?

lvsouza commented 3 years ago

I had this same problem. In my case the problem was in the format of the single image. I used a different converter for the ico format and it worked without problems.

I hope it helps you!

anshluu commented 2 years ago

I had this same problem. In my case the problem was in the format of the single image. I used a different converter for the ico format and it worked without problems.

I hope it helps you!

Thank you so much, this was perfect! This bug should be closed.

Detailed Explanation: When compiling with Electron Packager/Builder, I got this: WARNING: Could not find icon "C:\Users\AM\electron-quick-start\icon.ico", not updating app icon This told me that it was automatically searching for a .ico file. So I decided to rename the file from icon.png to icon.ico. This might of changed the file type, but the binaries of PNG wouldnt be converted to ICO. You need to use an PNG to ICO converter for this. Thank you to @lvsouza for sparking this answer!

lucaslgr commented 1 year ago

Thanks !! I've used this website to convert from png to ico choosing the size and without any background as png could provide https://redketchup.io/icon-converter

RolandDaum commented 1 year ago

Jo guys. Make sure your Icon is actually an .ico and not just a changned png with a different file ending!!!!

https://redketchup.io/icon-converter