cordova-electron icon indicating copy to clipboard operation
cordova-electron copied to clipboard

Windows icons not set

Open buu700 opened this issue 4 years ago • 3 comments

Bug Report

Problem

What is expected to happen?

The appx (Windows Store) package should have my app icon set as its icon.

If what's below isn't the correct way to configure this for Electron, the correct solution should ideally be documented.

What does actually happen?

My configuration below and icons are ignored; the default Electron icons are used instead.

<icon src="res/icon/windows/StoreLogo.png" target="StoreLogo" />
<icon src="res/icon/windows/SmallLogo.png" target="Square30x30Logo" />
<icon src="res/icon/windows/Square44x44Logo.png" target="Square44x44Logo" />
<icon src="res/icon/windows/Square70x70Logo.png" target="Square70x70Logo" />
<icon src="res/icon/windows/Square71x71Logo.png" target="Square71x71Logo" />
<icon src="res/icon/windows/Square150x150Logo.png" target="Square150x150Logo" />
<icon src="res/icon/windows/Square310x310Logo.png" target="Square310x310Logo" />
<icon src="res/icon/windows/Wide310x150Logo.png" target="Wide310x150Logo" />

Information

You can unzip the appx file and see that only the default Electron icons appear under assets.

Command or Code

cordova build electron

Environment, Platform, Device

macOS 10.14.6

Version information

Cordova 9.0.0

Checklist

  • [X] I searched for existing GitHub issues
  • [X] I updated all Cordova tooling to most recent version
  • [X] I included all the necessary information above

buu700 avatar Sep 28 '19 00:09 buu700

Until this is fixed, as a workaround, you can copy those icons into platforms/electron/build-res/appx/.

buu700 avatar Oct 03 '19 00:10 buu700

@buu700 When I copy those icons to the folder appx, I get the following error

The path (/p) parameter is: "my-project-location\platforms\electron\build\app.appx"
The mapping file (/f) parameter is: "my-project-location\platforms\electron\build\__appx-x64\mapping.txt"
Reading mapping file "my-project-location\platforms\electron\build\__appx-x64\mapping.txt"
MakeAppx : error: You can't add both "my-project-location\platforms\electron\build-res\appx\Square44X44Logo.png" and "C:\Users\{user}\AppData\Local\electron-builder\Cache\winCodeSign\winCodeSign-2.4.0\appxAssets\SampleAppx.44x44.png" to the output file as "assets\Square44x44Logo.png".

Am I missing something?

pjoriginal avatar Jun 03 '20 10:06 pjoriginal

To fix this problem I use this custom hook :

module.exports = function(context) {
  
  console.log('[HACK] Copy of all electron icons');

  //Prevent this running for other platforms.
  if ( context.opts.platforms.indexOf('electron') < 0 ) {
    return;
  }

  var fs   = require('fs'),
      path = require('path')

  const iconsPath = path.join(context.opts.projectRoot, 'resources/electron/icon/icon.png');
  const destination = path.join(context.opts.projectRoot, 'platforms/electron/build-res/icon.png');

  fs.createReadStream(iconsPath).pipe(fs.createWriteStream(destination));
};

And then call it from your Config.xml file

<platform name="electron">
        <hook src="hooks/copy-icons.js" type="after_prepare" />
        <icon src="resources/electron/icon/icon.png" />
</platform>

Jahrenski avatar Dec 02 '20 14:12 Jahrenski