Skip to content

Commit

Permalink
Fix application ID name
Browse files Browse the repository at this point in the history
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:

    <?xml version="1.0" encoding="utf-8"?>
    <Package ...>
        <Identity Name="12345MyCompany.MyApp" ... />
        ...
        <Applications>
            <Application Id="MyApp" ...>
                ...
            </Application>
        </Applications>
    </Package>

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:

<?xml version="1.0" encoding="utf-8"?>
<Package ...>
  <Identity Name="${identityName}" ... />
  ...
  <Applications>
    <Application Id="${packageName}" ...>
      ...
    </Application>
  </Applications>
</Package>

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: '19463Vidrio.Vidrio',  // This is actually the package name!
        packageName: 'Vidrio',  // This is actually the application id!!
        // ...
    });

This is very confusing, and has led to many tickets:

    electron-userland#82
    electron-userland#114
    electron-userland#103
    electron-userland#120

The best way forward would be to introduce a separate `program.applicationId` config,
which is used in preference to the `packageName`.

What is the correct/recommended format for a package name?

I created an account on [the Microsoft Partner Center](https://partner.microsoft.com/en-us/dashboard/windows/overview)
with the name `MyCompanyName`.
I then created a new Product on [the Microsoft Partner Center dashboard](https://partner.microsoft.com/en-us/dashboard/windows/overview)
I chose the name `FooBarBazTest`.
Under "Product Identity", Microsoft says:

    Include these values in your package manifest:

    Package/Identity/Name: 12345MyCompanyName.FooBarBazTest
    Package/Identity/Publisher: CN=6D79A3CE-7EB5-466E-8EE1-D370291F7800
    Package/Properties/PublisherDisplayName: MyCompanyName

Note the package name `12345MyCompanyName.FooBarBazTest`.

I am building an `.appx` package using [electron-windows-store](https://github.com/felixrieseberg/electron-windows-store).
This is not strictly relevant -- the important things are that this tool
makes a file which looks like this:

    PS C:\Users\james\vidrio\windows2> type .\myelectronapp\pre-appx\AppXManifest.xml
    <?xml version="1.0" encoding="utf-8"?>
    <Package
    xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
    xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
    xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities">
    <Identity Name="19463Vidrio.Vidrio"
        ProcessorArchitecture="x64"
        Publisher="CN=James Fisher, O=James Fisher, STREET=77 Broadwater Road, L=London, S=London, PostalCode=N17 6EP, C=GB"
        Version="0.3.0.0" />
    <Properties>
        <DisplayName>Vidrio</DisplayName>
        <PublisherDisplayName>Vidrio</PublisherDisplayName>
        <Description>No description entered</Description>
        <Logo>assets\SampleAppx.50x50.png</Logo>
    </Properties>
    <Resources>
        <Resource Language="en-us" />
    </Resources>
    <Dependencies>
        <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14316.0" MaxVersionTested="10.0.14316.0" />
    </Dependencies>
    <Capabilities>
        <rescap:Capability Name="runFullTrust"/>
    </Capabilities>
    <Applications>
        <Application Id="19463Vidrio.Vidrio" Executable="app/Vidrio.exe" EntryPoint="Windows.FullTrustApplication">
        <uap:VisualElements
        BackgroundColor="#464646"
        DisplayName="Vidrio"
        Square150x150Logo="assets\SampleAppx.150x150.png"
        Square44x44Logo="assets\SampleAppx.44x44.png"
        Description="Vidrio for Windows">
            <uap:DefaultTile Wide310x150Logo="assets\SampleAppx.310x150.png" />
        </uap:VisualElements>
        </Application>
    </Applications>
    </Package>

It builds this using this template:
https://github.com/felixrieseberg/electron-windows-store/blob/master/template/appxmanifest.xml

This comes from this config:

  await convertToWindowsStore({
    name: '19463Vidrio.Vidrio',
    packageName: 'Vidrio',  // Pre-Electron Vidrio was using the name '19463Vidrio.Vidrio' but this is not even valid according to makeappx?!
  });

 makes the following call to `makeappx.exe`:

PS C:\Users\james\vidrio\windows2> & 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\makeappx.exe' pack /d myelectronapp\pre-appx /p myelectronapp\19463Vidrio.Vidrio.appx /o
  • Loading branch information
jameshfisher committed May 5, 2020
1 parent ecdcee1 commit 2147c80
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ These are all options for the CLI:
-i, --input-directory <path> Directory containing your application
-o, --output-directory <path> Output directory for the appx
-p, --package-version <version> Version of the app package
-n, --package-name <name> Name of the app package
-n, --package-name <name> Name of the app package (example: 12345MyCompany.Ghost)
--package-display-name <displayName> Display name of the package
--package-description <description> Description of the package
--package-background-color <color> Background color for the app icon (example: #464646)
-e, --package-executable <executablePath> Path to the package executable
--application-id <applicationId> Application id (example: Ghost)
-a, --assets <assetsPath> Path to the visual assets for the appx
-m, --manifest <manifestPath> Path to a manifest, if you want to be overwritten
-d, --deploy <true|false> Should the app be deployed after creation?
--identity-name <name> Name for identity
--publisher <publisher> Publisher to use (example: CN=developmentca)
--publisher-display-name <publisherDisplayName> Publisher display name to use
--make-pri <true|false> Use makepri.exe (you don't need to unless you know you do)
Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions bin/windowsstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ program
.option('-i, --input-directory <path>', 'Directory containing your application')
.option('-o, --output-directory <path>', 'Output directory for the appx')
.option('-p, --package-version <version>', 'Version of the app package')
.option('-n, --package-name <name>', 'Name of the app package')
.option('--identity-name <name>', 'Name for identity')
.option('-n, --package-name <name>', 'Name of the app package (example: 12345MyCompany.Ghost)')
.option('--identity-name <name>', 'Name for identity (deprecated; use --package-name)')
.option('--package-display-name <displayName>', 'Dispay name of the package')
.option('--package-description <description>', 'Description of the package')
.option('--package-background-color <color>', 'Background color for the app icon (example: #464646)')
.option('--application-id <applicationId>', 'Application id (example: Ghost)')
.option('-e, --package-executable <executablePath>', 'Path to the package executable')
.option('-a, --assets <assetsPath>', 'Path to the visual assets for the appx')
.option('-m, --manifest <manifestPath>', 'Path to a manifest, if you want to overwrite the default one')
Expand Down
2 changes: 1 addition & 1 deletion lib/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions lib/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
{
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template/appxmanifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<rescap:Capability Name="runFullTrust"/>
</Capabilities>
<Applications>
<Application Id="${packageName}" Executable="${packageExecutable}" EntryPoint="Windows.FullTrustApplication">
<Application Id="${applicationId}" Executable="${packageExecutable}" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements
BackgroundColor="${packageBackgroundColor}"
DisplayName="${packageDisplayName}"
Expand Down

0 comments on commit 2147c80

Please sign in to comment.