From aa70204a9f07d2fd4bb9f79acac964021e6695d2 Mon Sep 17 00:00:00 2001 From: Jim Fisher Date: Tue, 5 May 2020 09:59:43 +0100 Subject: [PATCH] Fix application ID name There's a lot of terminological/conceptual confusion in the current API. An .appx file should have an `AppXManifest.xml` which looks like the following, omitting unimportant elements: ... ... Notice that there are two separate identities: the Package Name, and the Application Id. When you run `electron-windows-store`, it generates an `AppXManifest.xml` from the config you supply. [The template is here](https://github.com/felixrieseberg/electron-windows-store/blob/master/template/appxmanifest.xml) and it looks like: ... ... Notice in the variable names: it calls the package name `identityName`, and calls the application id `packageName`. These template variables are subtituted by the user-supplied config like so: lib/convert.js: result = result.replace(/\${identityName}/g, program.identityName || program.packageName) lib/convert.js: result = result.replace(/\${packageName}/g, program.packageName) This means, to create a correct `AppXManifest.xml`, you need to call it like so: const convertToWindowsStore = require('electron-windows-store'); convertToWindowsStore({ identityName: '12345MyCompany.Ghost', // This is actually the package name! packageName: 'Ghost', // This is actually the application id!! // ... }); This is very confusing, and has led to many tickets: https://github.com/felixrieseberg/electron-windows-store/issues/82 https://github.com/felixrieseberg/electron-windows-store/issues/114 https://github.com/felixrieseberg/electron-windows-store/issues/103 https://github.com/felixrieseberg/electron-windows-store/issues/120 The best way forward would be to introduce a separate `program.applicationId` config, which is used in preference to the `packageName`. --- README.md | 7 ++++--- bin/windowsstore.js | 5 +++-- lib/convert.js | 2 +- lib/params.js | 10 ++++++++-- template/appxmanifest.xml | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 05bba9d..f6d9082 100644 --- a/README.md +++ b/README.md @@ -66,15 +66,15 @@ These are all options for the CLI: -i, --input-directory Directory containing your application -o, --output-directory Output directory for the appx -p, --package-version Version of the app package - -n, --package-name Name of the app package + -n, --package-name Name of the app package (example: 12345MyCompany.Ghost) --package-display-name Display name of the package --package-description Description of the package --package-background-color Background color for the app icon (example: #464646) -e, --package-executable Path to the package executable + --application-id Application id (example: Ghost) -a, --assets Path to the visual assets for the appx -m, --manifest Path to a manifest, if you want to be overwritten -d, --deploy Should the app be deployed after creation? - --identity-name Name for identity --publisher Publisher to use (example: CN=developmentca) --publisher-display-name Publisher display name to use --make-pri Use makepri.exe (you don't need to unless you know you do) @@ -101,10 +101,11 @@ convertToWindowsStore({ inputDirectory: 'C:\\input\\', outputDirectory: 'C:\\output\\', packageVersion: '1.0.0.0', - packageName: 'Ghost', + packageName: '12345MyCompany.Ghost', packageDisplayName: 'Ghost Desktop', packageDescription: 'Ghost for Desktops', packageExecutable: 'app/Ghost.exe', + applicationId: 'Ghost', assets: 'C:\\assets\\', manifest: 'C:\\AppXManifest.xml', deploy: false, diff --git a/bin/windowsstore.js b/bin/windowsstore.js index 27f6460..9f6e57b 100644 --- a/bin/windowsstore.js +++ b/bin/windowsstore.js @@ -26,11 +26,12 @@ program .option('-i, --input-directory ', 'Directory containing your application') .option('-o, --output-directory ', 'Output directory for the appx') .option('-p, --package-version ', 'Version of the app package') - .option('-n, --package-name ', 'Name of the app package') - .option('--identity-name ', 'Name for identity') + .option('-n, --package-name ', 'Name of the app package (example: 12345MyCompany.Ghost)') + .option('--identity-name ', 'Name for identity (deprecated; use --package-name)') .option('--package-display-name ', 'Dispay name of the package') .option('--package-description ', 'Description of the package') .option('--package-background-color ', 'Background color for the app icon (example: #464646)') + .option('--application-id ', 'Application id (example: Ghost)') .option('-e, --package-executable ', 'Path to the package executable') .option('-a, --assets ', 'Path to the visual assets for the appx') .option('-m, --manifest ', 'Path to a manifest, if you want to overwrite the default one') diff --git a/lib/convert.js b/lib/convert.js index 83b33e8..b6f159b 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -135,7 +135,7 @@ function convertWithFileCopy (program) { result = result.replace(/\${publisherDisplayName}/g, program.publisherDisplayName || 'Reserved') result = result.replace(/\${identityName}/g, program.identityName || program.packageName) result = result.replace(/\${packageVersion}/g, program.packageVersion) - result = result.replace(/\${packageName}/g, program.packageName) + result = result.replace(/\${applicationId}/g, program.applicationId || program.packageName) result = result.replace(/\${packageExecutable}/g, executable) result = result.replace(/\${packageDisplayName}/g, program.packageDisplayName || program.packageName) result = result.replace(/\${packageDescription}/g, program.packageDescription || program.packageName) diff --git a/lib/params.js b/lib/params.js index 3da92e2..1012e1c 100644 --- a/lib/params.js +++ b/lib/params.js @@ -53,10 +53,16 @@ module.exports = function (program) { }, when: () => (!program.outputDirectory) }, + { + name: 'applicationId', + type: 'input', + message: "Please enter your app's application id (Example: Ghost): ", + when: () => (!program.applicationId) + }, { name: 'packageName', type: 'input', - message: "Please enter your app's package name (name of your exe - without '.exe'): ", + message: "Please enter your app's package name (Example: 12345MyCompany.Ghost): ", when: () => (!program.packageName) }, { @@ -76,7 +82,7 @@ module.exports = function (program) { inquirer.prompt(questions) .then((answers) => { if (!program.packageExecutable && program.containerVirtualization) { - program.packageExecutable = `C:\\Users\\ContainerAdministrator\\AppData\\Roaming\\e\\${program.packageName}.exe` + program.packageExecutable = `C:\\Users\\ContainerAdministrator\\AppData\\Roaming\\e\\${program.applicationId}.exe` } Object.assign(program, answers) diff --git a/template/appxmanifest.xml b/template/appxmanifest.xml index 15655c0..70acead 100644 --- a/template/appxmanifest.xml +++ b/template/appxmanifest.xml @@ -23,7 +23,7 @@ - +