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

Windows Appx build with custom icons throws "Appx manifest not found or is invalid" error

Open jklp opened this issue 1 year ago • 0 comments

  • Electron-Builder Version: 23.3.3
  • Node Version: 16.13.1
  • Electron Version: 19.0.4
  • Electron Type (current, beta, nightly): current
  • Target: appx

I'm on a 2021 M1 Macbook Pro 16", running Parallels Desktop 17.1.4 (51567) with a Windows 11 Home (21H2, 22000.856) environment.

I'm attempting to build an appx, and in my electron-builder.yml I've got the following (I've cut out the irrelevant parts):

appId: MyApp
files: 
  - build/**/*
  - node_modules/**/*
directories:
  buildResources: electron/assets
win:
  target: 
    - appx
  icon: electron/assets/icon.ico
appx:
  applicationId: app.id.myapp
  identityName: 9999app.id.myapp
  publisher: CN=XXXXX-XXXX
  publisherDisplayName: MyApp

In ./electron/assets, I've created an appx directory with my app icons using the instructions here - https://www.electron.build/configuration/appx#appx-assets, which has the following files:

  • Square44x44Logo.png
  • Square150x150Logo.png
  • StoreLogo.png
  • Wide310x150Logo.png

In my package.json I've got the following (I've only pasted the relevant sections)

"scripts": {
  "build-electron": "react-scripts build && compress-cra",
  "electron-package-win": ".\\node_modules\\.bin\\electron-builder -c.extraMetadata.main=build\\electron.js --win",
  "preelectron-package-win": "npm run build-electron"
}

When I run npm run electron-package-win, I get the following error

error PRI191: 0x800700c1 - Appx manifest not found or is invalid. Please ensure well-formed manifest file is present. Or specify an index name with /in switch.

  at Z:\dev\src\myapp\client\node_modules\builder-util\src\util.ts:133:18
  at ChildProcess.exithandler (node:child_process:404:5)
  at ChildProcess.emit (node:events:390:28)
  at maybeClose (node:internal/child_process:1064:16)
  at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)

And seems to be failing on this command:

C:\Users\jklp\AppData\Local\electron-builder\Cache\winCodeSign\winCodeSign-2.6.0\windows-10\x64\makepri.exe new /Overwrite /Manifest Z:\dev\src\myapp\client\dist\__appx-x64\AppxManifest.xml /ProjectRoot Z:\dev\src\myapp\client\dist\__appx-x64\appx /ConfigXml Z:\dev\src\myapp\client\node_modules\app-builder-lib\templates\appx\priconfig.xml /OutputFile Z:\dev\src\myapp\client\dist\__appx-x64\resources.pri

When I run that command in the command line (I'm using PowerShell), it throws the same error as if I was running npm run electron-package-win.

After the error, no .appx is built.

I've found if I remove the ./electron/assets/appx/ directory and run npm run electron-package-win, the .appx is built correctly, though it uses the default icons from the following directory (this is what's stopping me from submitting to the Microsoft Store - invalid icons).

C:\Users\jklp\AppData\Local\electron-builder\Cache\winCodeSign\winCodeSign-2.6.0\appxAssets\

I'm not sure what the fix is but this might be a clue. When building it looks like electron-builder creates a ./dist/__appx-64 directory. If I delete the ./electron/assets/appx/ directory deleted, a mapping.txt file is created in __appx-x64 which maps the icons from the appxAssets directory above to the ./assets/ directory in the .appx package (this is how I found the location of the default icons).

When building with the the ./electron/assets/appx/ directory NOT deleted, no mapping.txt file is created.

Unfortunately when I copied the mapping.txt file into that __appx-x64 directory and ran makepri.exe (full command above) I thought I would have worked, but unfortunately it still returns the error PRI191: 0x800700c1 - Appx manifest not found or is invalid. Please ensure well-formed manifest file is present. Or specify an index name with /in switch. error.

Not a show stopper - I've found if I copy my icons into ./appxAssets, I can package those icons into the .appx, though it doesn't allow me to add scaled assets e.g. files ending in *.scaled-200.png.

If you'd like more information let me know - I've got full logs and directories saved and I can send snippets if requested.

Thanks!

jklp avatar Sep 06 '22 04:09 jklp