electron-userland / electron-windows-store

:package: Turn Electron Apps into Windows AppX Packages
MIT License
681 stars 87 forks source link

No support for creating a .appxbundle #136

Open jameshfisher opened 4 years ago

jameshfisher commented 4 years ago

When submitting my .appx file to the Microsoft Store, I get the error:

A previous submission for this app was released with a Windows 10 .msixbundle or .appxbundle. Subsequent submissions must continue to contain a Windows 10 .msixbundle or .appxbundle.

So producing an .appx, as electron-windows-store does, is not always sufficient for the Microsoft Store. We need to create a .appxbundle from this. But I don't see options for this in electron-windows-store API.

This answer provides some clues, but it's not very pretty. And it produces an unsigned .appxbundle, meaning I have to manually re-sign the .appxbundle it creates.

jameshfisher commented 4 years ago

I got this working. I'd be willing to submit a PR adding this support. However it seems like this repo is dead/unmaintained

jameshfisher commented 4 years ago

Here's the essence of my soln:


const convertToWindowsStore = require('electron-windows-store');
const electronWindowsStoreUtils = require('electron-windows-store/lib/utils');

const opts = { /* */ };

await convertToWindowsStore(opts);

// This is how electron-windows-store seems to behave
const appxPath = `${opts.outputDirectory}\\${opts.packageName}.appx`;

const APPXBUNDLE_FILEPATH = 'some\\output\\dir\\MyAppName.appxbundle';

const TMP_APPXBUNDLE_MAP_FILEPATH = 'some\\tmp\\dir\\AppxBundle.map';

// https://docs.microsoft.com/en-us/windows/msix/package/create-app-package-with-makeappx-tool#mapping-files
fs.writeFileSync(TMP_APPXBUNDLE_MAP_FILEPATH, [
    '[Files]',
    `"${appxPath}" "MyAppName.appx"`,  // Note: the filename within the .appxbundle seems to be unimportant?
    ].join("\n"));

// This makes an unsigned bundle ...
const makeappx = path.join(windowsKitPath, 'makeappx.exe');
await electronWindowsStoreUtils.executeChildProcess(makeappx, 
    ['bundle', '/f', TMP_APPXBUNDLE_MAP_FILEPATH, '/p', APPXBUNDLE_FILEPATH, '/o']);

// ... so we have to sign it with:
const signtool = path.join(windowsKitPath, 'signtool.exe');
await electronWindowsStoreUtils.executeChildProcess(signtool, 
    ['sign', '-f', opts.devCert, '-p', opts.certPass, '-fd', 'SHA256', '-v', APPXBUNDLE_FILEPATH]);
mahnunchik commented 4 years ago

@jameshfisher Why are you signing the application/bundle? It looks like it might not be signed for submission to the Store.

jameshfisher commented 4 years ago

I'm signing it for submission to the Microsoft Store, which requires a bundle signed with my Microsoft developer identity

mahnunchik commented 3 years ago

@jameshfisher I was able to submit not signed .appxbundle to Store.

@felixrieseberg is this project dead?

mahnunchik commented 3 years ago

@felixrieseberg could you please pay attention to this issue.