Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support completely custom AppxManifest.xml #8609

Merged

Conversation

iongion
Copy link
Contributor

@iongion iongion commented Oct 17, 2024

Copy link

changeset-bot bot commented Oct 17, 2024

🦋 Changeset detected

Latest commit: 7f59a95

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
app-builder-lib Major
dmg-builder Major
electron-builder-squirrel-windows Major
electron-builder Major
electron-forge-maker-appimage Major
electron-forge-maker-nsis-web Major
electron-forge-maker-nsis Major
electron-forge-maker-snap Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mmaietta
Copy link
Collaborator

mmaietta commented Oct 17, 2024

Thanks for the contribution! 🙂

This functionality should already exist in an electron-builder Hook though. It's passed a path to the file on disk, just replace the file at that path?

/**
* The function (or path to file or module id) to be run after Appx manifest created on disk - not packed into .appx package yet.
*/
readonly appxManifestCreated?: Hook<string, any> | string | null

@iongion
Copy link
Contributor Author

iongion commented Oct 17, 2024

@mmaietta It is very confusing - I don't see how appxManifestCreated hook is returning a totally new manifest or something to replace the default path.

I think the PR should offer a way to replace two types of manifests, one just like the default, that has template variables and one raw XML - as is, no interpolation at all.

So that if should just become

const manifestFile = this.options.customManifestPath || stageDir.getTempFile("AppxManifest.xml")
await this.writeManifest(manifestFile, arch, await this.computePublisherName(), userAssets)

But I don't know how distinguish between raw and template based one.

@iongion
Copy link
Contributor Author

iongion commented Oct 17, 2024

I think I got it, but let's say we have this

So to support such a thing, the original template namespaces must be extended, plus new expressions for extensions.

If one would have direct template access, he could just

  1. Add extra namespace to root element
xmlns:desktop2="http://schemas.microsoft.com/appx/manifest/desktop/windows10/2"
  1. Added the desktop2 rules for the firewall inside the inner most Application node
      <Extensions>
        <desktop2:Extension Category="windows.firewallRules">
          <desktop2:FirewallRules>
            <desktop2:Rule Direction="in" Protocol="TCP" LocalPortMin="22022" LocalPortMax="24044" Profile="all" Action="allow" />
          </desktop2:FirewallRules>
        </desktop2:Extension>
      </Extensions>

With the existing hook, I came up to this - it does the job, but it is horrendous

  appxManifestCreated: async (appxPath) => {
    const manifest = await xml2js.parseStringPromise(fs.readFileSync(appxPath, "utf8").toString());
    manifest.Package.$["xmlns:desktop2"] = "http://schemas.microsoft.com/appx/manifest/desktop/windows10/2";
    const application = manifest.Package.Applications[0].Application[0];
    application.Extensions = application.Extensions || [];
    application.Extensions.push({
      "desktop2:Extension": {
        $: {
          Category: "windows.fileTypeAssociation",
        },
        "desktop2:FirewallRules": {
          "desktop2:Rule": {
            $: {
              Direction: "in",
              Profile: "private",
              Protocol: "TCP",
              LocalPortMin: "22022",
              LocalPortMax: "24044",
              Action: "allow",
            },
          },
        },
      },
    });
    const builder = new xml2js.Builder();
    const manifestDocument = builder.buildObject(manifest);
    fs.writeFileSync(appxPath, manifestDocument);
  }

@mmaietta
Copy link
Collaborator

mmaietta commented Oct 17, 2024

Ohhhh I see, you want to be able to provide a custom AppxManifest that allows for both template or raw. The hook only allows to replace the file with a raw manifest.

But I don't know how distinguish between raw and template based one.

What if we allow both? Let the writeManifest parse for template vars, if none found, then the logic does no replacement. It think it should only require pulling in the temp file into the writeManifest function and alter the signature to return the file path

private async writeManifest(arch: Arch, publisher: string, userAssets: Array<string>): string {
   const outFile = stageDir.getTempFile("AppxManifest.xml")
   // logic
   const manifest = (await readFile(this.options.customManifestPath || path.join(getTemplatePath("appx"), "appxmanifest.xml"), "utf8"))).replace(/\${([a-zA-Z0-9]+)}/g, (match, p1): string => {
   // more logic

Related note, I'll also need two unit test cases written for this functionality if we go with that approach ☝️ . One with a raw manifest, and the other with a template manifest. I'm happy to help contribute to this PR by writing the unit tests, but I'll need both manifests from you committed to this branch first for me to build on top of 😄

@iongion
Copy link
Contributor Author

iongion commented Oct 17, 2024

That's great

Here it is a manifest that totally works for my project https://container-desktop.com

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop2="http://schemas.microsoft.com/appx/manifest/desktop/windows10/2">
  <Identity Name="IonutStoica.ContainerDesktop" ProcessorArchitecture="x64" Publisher="CN=52408AA8-2ECC-4E48-9A2C-6C1F69841C79" Version="5.2.13.0"/>
  <Properties>
    <DisplayName>Container Desktop</DisplayName>
    <PublisherDisplayName>Ionut.Stoica</PublisherDisplayName>
    <Description>Container Desktop</Description>
    <Logo>assets\StoreLogo.png</Logo>
  </Properties>
  <Resources>
    <Resource Language="en-US"/>
  </Resources>
  <Dependencies>
    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.18362.0" MaxVersionTested="10.0.18362.0"/>
  </Dependencies>
  <Capabilities>
    <Capability Name="internetClient"/>
    <Capability Name="privateNetworkClientServer"/>
    <rescap:Capability Name="runFullTrust"/>
  </Capabilities>
  <Applications>
    <Application Id="IonutStoica.ContainerDesktop" Executable="app\Container Desktop.exe" EntryPoint="Windows.FullTrustApplication">
      <uap:VisualElements BackgroundColor="#464646" DisplayName="Container Desktop" Square150x150Logo="assets\Square150x150Logo.png" Square44x44Logo="assets\Square44x44Logo.png" Description="Container Desktop">
        <uap:DefaultTile Wide310x150Logo="assets\Wide310x150Logo.png" Square310x310Logo="assets\LargeTile.png" Square71x71Logo="assets\SmallTile.png"/>
      </uap:VisualElements>
    </Application>
  </Applications>
  <Extensions>
    <desktop2:Extension Category="windows.firewallRules">
      <desktop2:FirewallRules Executable="app\bin\container-desktop-ssh-relay.exe">
        <desktop2:Rule Direction="in" Profile="private" IPProtocol="TCP" LocalPortMin="22022" LocalPortMax="24044"/>
      </desktop2:FirewallRules>
    </desktop2:Extension>
  </Extensions>
</Package>

To generate this manifest with the hook, I had to do this:

  appxManifestCreated: async (appxPath) => {
    const manifest = await xml2js.parseStringPromise(fs.readFileSync(appxPath, "utf8").toString());
    manifest.Package.$["xmlns:uap"] = "http://schemas.microsoft.com/appx/manifest/uap/windows10";
    manifest.Package.$["xmlns:desktop"] = "http://schemas.microsoft.com/appx/manifest/desktop/windows10";
    manifest.Package.$["xmlns:desktop2"] = "http://schemas.microsoft.com/appx/manifest/desktop/windows10/2";
    manifest.Package.Capabilities = [
      [
        { Capability: { $: { Name: "internetClient" } } },
        { Capability: { $: { Name: "privateNetworkClientServer" } } },
        { "rescap:Capability": { $: { Name: "runFullTrust" } } },
      ],
    ];
    manifest.Package.Extensions = manifest.Package.Extensions || [];
    manifest.Package.Extensions.push({
      "desktop2:Extension": {
        $: {
          Category: "windows.firewallRules",
        },
        "desktop2:FirewallRules": {
          $: {
            Executable: "app\\bin\\container-desktop-ssh-relay.exe",
          },
          "desktop2:Rule": {
            $: {
              Direction: "in",
              Profile: "private",
              IPProtocol: "TCP",
              LocalPortMin: "22022",
              LocalPortMax: "24044",
            },
          },
        },
      },
    });
    const builder = new xml2js.Builder();
    const manifestDocument = builder.buildObject(manifest);
    fs.writeFileSync(appxPath, manifestDocument);
  }

Because of the use of xml2js it generates totally safe XML - now I don't know what to say, your recommendation worked perfectly but is hard for the brain, no existing examples, hard to even find documentation on Microsoft, best thing for me was to lookup in all the apps I installed from Microsoft Store and inspire from them, for example, the firewall rules are from Skype's manifest.

You can close the ticket and not do anything if we can somehow improve just the documentation on how to use the custom hook with good examples as above as it touches all points. Basically Custom anything inside the Appx template - and also XML safe!

@mmaietta
Copy link
Collaborator

mmaietta commented Oct 17, 2024

Thanks! Alrighty, I can take it from here if you'd like (unless you have commits to still push 🙂 )

Thoughts on having the manifest default to reading from the Resources dir unless it's an absolute path?

@iongion
Copy link
Contributor Author

iongion commented Oct 17, 2024

Nothing more to add, go for it, thank you so much!

@mmaietta
Copy link
Collaborator

@iongion PR is ready but I need the snapshots regenerated for it as I can't build the AppX on my mac M2.
Can you please run this from cmd line after pulling in the latest changes in this PR?

pnpm compile && UPDATE_SNAPSHOT=true TEST_FILES=appxTest pnpm ci:test

@iongion
Copy link
Contributor Author

iongion commented Oct 18, 2024

Just did, it needs some changes

  1. I had to modify the command you share so that it works in powershell, just needed to prefix the env part with cross-env (from https://www.npmjs.com/package/cross-env)
pnpm compile && cross-env UPDATE_SNAPSHOT=true TEST_FILES=appxTest pnpm ci:test
  1. Needed to use "${executable}" as the firewall rules need to find one that exists, so let's just use the default one
    <desktop2:FirewallRules Executable="${executable}">
      <desktop2:Rule Direction="in" Profile="private" IPProtocol="TCP" LocalPortMin="22022" LocalPortMax="24044"/>
    </desktop2:FirewallRules>
  1. Modified the snapshot too
    <desktop2:FirewallRules Executable="app\\Test App ßW.exe">
      <desktop2:Rule Direction="in" Profile="private" IPProtocol="TCP" LocalPortMin="22022" LocalPortMax="24044"/>
    </desktop2:FirewallRules>
  1. Had to provide a custom path to a more recent signtool
$env:SIGNTOOL_PATH="C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe"
  1. Finally ran the tests
pnpm compile && cross-env UPDATE_SNAPSHOT=true TEST_FILES=appxTest pnpm ci:test

Now all tests pass

> @electron-builder/monorepo@ compile C:\Workspace\is\electron-builder
> tsc --build


> @electron-builder/monorepo@ ci:test C:\Workspace\is\electron-builder
> node ./test/out/helpers/runTests.js

Test files: appxTest
electron-builder  version=26.0.0-alpha.3 os=10.0.22631
loaded configuration  file=package.json ("build" field)
writing effective config  file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-GuJIGO\test-project-0\dist\builder-effective-config.yaml
skipped dependencies rebuild  reason=npmRebuild is set to false
packaging       platform=win32 arch=x64 electron=23.3.10 appOutDir=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-GuJIGO\test-project-0\dist\win-unpacked
updating asar integrity executable resource  executablePath=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-GuJIGO\test-project-0\dist\win-unpacked\Test App ßW.exe
executing @electron/fuses  electronPath=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-GuJIGO\test-project-0\dist\win-unpacked\Test App ßW.exe
empty password will be used for code signing  reason=CSC_KEY_PASSWORD is not defined
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-GuJIGO\test-project-0\dist\win-unpacked\Test App ßW.exe
signing         file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-GuJIGO\test-project-0\dist\win-unpacked\Test App ßW.exe certificateFile=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-GuJIGO\3.p12
building        target=AppX arch=x64 file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-GuJIGO\test-project-0\dist\Test App ßW 1.1.0.appx
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-GuJIGO\test-project-0\dist\Test App ßW 1.1.0.appx
signing         file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-GuJIGO\test-project-0\dist\Test App ßW 1.1.0.appx certificateFile=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-GuJIGO\3.p12
electron-builder  version=26.0.0-alpha.3 os=10.0.22631
loaded configuration  file=package.json ("build" field)
writing effective config  file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-JmjHlr\test-project-4\dist\builder-effective-config.yaml
skipped dependencies rebuild  reason=npmRebuild is set to false
packaging       platform=win32 arch=x64 electron=23.3.10 appOutDir=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-JmjHlr\test-project-4\dist\win-unpacked
updating asar integrity executable resource  executablePath=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-JmjHlr\test-project-4\dist\win-unpacked\Test App ßW.exe
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-JmjHlr\test-project-4\dist\win-unpacked\Test App ßW.exe
building        target=AppX arch=x64 file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-JmjHlr\test-project-4\dist\Test App ßW 1.1.0.appx
AppX is not signed  reason=Windows Store only build
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-JmjHlr\test-project-4\dist\Test App ßW 1.1.0.appx
electron-builder  version=26.0.0-alpha.3 os=10.0.22631
loaded configuration  file=package.json ("build" field)
writing effective config  file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-KqLY3P\test-project-7\dist\builder-effective-config.yaml
skipped dependencies rebuild  reason=npmRebuild is set to false
packaging       platform=win32 arch=x64 electron=23.3.10 appOutDir=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-KqLY3P\test-project-7\dist\win-unpacked
updating asar integrity executable resource  executablePath=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-KqLY3P\test-project-7\dist\win-unpacked\Test App ßW.exe
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-KqLY3P\test-project-7\dist\win-unpacked\Test App ßW.exe
signing         file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-KqLY3P\test-project-7\dist\win-unpacked\Test App ßW.exe certificateFile=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-KqLY3P\a.p12
building        target=AppX arch=x64 file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-KqLY3P\test-project-7\dist\Test App ßW 1.1.0.appx
Remove the 01234
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-KqLY3P\test-project-7\dist\Test App ßW 1.1.0.appx
signing         file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-KqLY3P\test-project-7\dist\Test App ßW 1.1.0.appx certificateFile=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-KqLY3P\a.p12
electron-builder  version=26.0.0-alpha.3 os=10.0.22631
loaded configuration  file=package.json ("build" field)
writing effective config  file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\builder-effective-config.yaml
skipped dependencies rebuild  reason=npmRebuild is set to false
packaging       platform=win32 arch=ia32 electron=23.3.10 appOutDir=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\win-ia32-unpacked
updating asar integrity executable resource  executablePath=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\win-ia32-unpacked\Test App ßW.exe
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\win-ia32-unpacked\Test App ßW.exe
signing         file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\win-ia32-unpacked\Test App ßW.exe certificateFile=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\e.p12
building        target=AppX arch=ia32 file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\Test App ßW 1.1.0 ia32.appx
skipped dependencies rebuild  reason=npmRebuild is set to false
packaging       platform=win32 arch=x64 electron=23.3.10 appOutDir=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\win-unpacked
updating asar integrity executable resource  executablePath=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\win-unpacked\Test App ßW.exe
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\Test App ßW 1.1.0 ia32.appx
signing         file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\Test App ßW 1.1.0 ia32.appx certificateFile=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\e.p12
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\win-unpacked\Test App ßW.exe
signing         file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\win-unpacked\Test App ßW.exe certificateFile=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\e.p12
building        target=AppX arch=x64 file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\Test App ßW 1.1.0.appx
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\Test App ßW 1.1.0.appx
signing         file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\test-project-b\dist\Test App ßW 1.1.0.appx certificateFile=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-DINy5G\e.p12
electron-builder  version=26.0.0-alpha.3 os=10.0.22631
loaded configuration  file=package.json ("build" field)
writing effective config  file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-YsLC9W\test-project-h\dist\builder-effective-config.yaml
skipped dependencies rebuild  reason=npmRebuild is set to false
packaging       platform=win32 arch=x64 electron=23.3.10 appOutDir=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-YsLC9W\test-project-h\dist\win-unpacked
updating asar integrity executable resource  executablePath=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-YsLC9W\test-project-h\dist\win-unpacked\Test App ßW.exe
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-YsLC9W\test-project-h\dist\win-unpacked\Test App ßW.exe
building        target=AppX arch=x64 file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-YsLC9W\test-project-h\dist\Test App ßW 1.1.0.appx
AppX is not signed  reason=Windows Store only build
custom appx manifest found  manifestPath=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-YsLC9W\test-project-h\build\custom-template-manifest.xml
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-YsLC9W\test-project-h\dist\Test App ßW 1.1.0.appx
electron-builder  version=26.0.0-alpha.3 os=10.0.22631
loaded configuration  file=package.json ("build" field)
writing effective config  file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-dlLGB9\test-project-k\dist\builder-effective-config.yaml
skipped dependencies rebuild  reason=npmRebuild is set to false
packaging       platform=win32 arch=x64 electron=23.3.10 appOutDir=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-dlLGB9\test-project-k\dist\win-unpacked
updating asar integrity executable resource  executablePath=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-dlLGB9\test-project-k\dist\win-unpacked\Test App ßW.exe
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-dlLGB9\test-project-k\dist\win-unpacked\Test App ßW.exe
building        target=AppX arch=x64 file=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-dlLGB9\test-project-k\dist\Test App ßW 1.1.0.appx
AppX is not signed  reason=Windows Store only build
custom appx manifest found  manifestPath=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-dlLGB9\test-project-k\build\custom-manifest.xml
signing with signtool.exe  path=C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-dlLGB9\test-project-k\dist\Test App ßW 1.1.0.appx
 PASS  src/windows/appxTest.ts (25.392 s)
  √ AppX (5693 ms)
  √ auto launch (2434 ms)
  √ application id (4579 ms)
  √ languages and not signed (windows store only) (6909 ms)
  √ custom template appmanifest.xml (2416 ms)
  √ custom raw appmanifest.xml (2532 ms)
  ○ skipped certificateSubjectName

Test Suites: 1 passed, 1 total
Tests:       1 skipped, 6 passed, 7 total
Snapshots:   8 passed, 8 total
Time:        25.455 s
Ran all test suites matching /appxTest\.ts$/i.

NOTE - If using the bundled signtool, then the tests will fail because of this

    Exit code: 1. Command failed: C:\Users\istoica\AppData\Local\electron-builder\Cache\winCodeSign\winCodeSign-2.6.0\windows-10\x64\signtool.exe sign /tr http://timestamp.digicert.com /f C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-LaNxCo\e.p12 /fd sha256 /td sha256 /d Test App ßW /du http://foo.example.com /p 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 (sha256 hash) /debug C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-LaNxCo\test-project-b\dist\Test App ßW 1.1.0 ia32.appx
    SignTool Error: Multiple signature support is not implemented for this filetype.
    SignTool Error: An error occurred while attempting to sign: C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-LaNxCo\test-project-b\dist\Test App W 1.1.0 ia32.appx


    The following certificates were considered:
        Issued to: Foo, Inc
        Issued by: Foo, Inc
        Expires:   Sun Jan 01 01:59:59 2040
        SHA1 hash: 2AE9AFEB4382EE1085381999355560BE5E70A610

    After EKU filter, 1 certs were left.
    After expiry filter, 1 certs were left.
    After Private Key filter, 1 certs were left.
    The following certificate was selected:
        Issued to: Foo, Inc
        Issued by: Foo, Inc
        Expires:   Sun Jan 01 01:59:59 2040
        SHA1 hash: 2AE9AFEB4382EE1085381999355560BE5E70A610


    The following additional certificates will be attached:
    Done Adding Additional Store

    Number of files successfully Signed: 0
    Number of warnings: 0
    Number of errors: 1

    SignTool Error: Multiple signature support is not implemented for this filetype.
    SignTool Error: An error occurred while attempting to sign: C:\Users\istoica\AppData\Local\Temp\et-5b4743cbbddfe15ab0632284ed5747fe\t-LaNxCo\test-project-b\dist\Test App W 1.1.0 ia32.appx

Just a FYI, there is another tool to sign windows executables, which works on all operating systems - https://ebourg.github.io/jsign/ but it is java based

@mmaietta
Copy link
Collaborator

So I don't seem to be running into any issue with signtool, rather it's something wrong with the template manifest (probably why allowing a custom one was never previously implemented since the error messages are so obscure.

- custom template appmanifest.xml
   ...more logs

    MakeAppx : error: 0x80080204 - The specified package format is not valid: The package manifest is not valid.

Can you take a look at custom-template-manifest.xml and see what's wrong with it?

@electron-userland electron-userland deleted a comment from netlify bot Nov 5, 2024
@mmaietta
Copy link
Collaborator

@iongion are you willing to try this out in an alpha release of electron-builder or do you need the electron-builder version be in GA (non-alpha)?

@mmaietta mmaietta requested a review from beyondkmp November 21, 2024 14:55
.vscode/launch.json Outdated Show resolved Hide resolved
@mmaietta mmaietta requested a review from beyondkmp December 6, 2024 17:19
@mmaietta mmaietta merged commit d672b04 into electron-userland:master Dec 27, 2024
9 checks passed
mmaietta pushed a commit that referenced this pull request Jan 26, 2025
## 26.0.0

### Major Changes

-
[#8782](#8782)
[`633490cb`](633490c)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: removing
conditional logic that would build HFS+ dmg on non-arm64 macs as HFS+
was sunset in macos 15.2
-
[#8582](#8582)
[`6a9597b4`](6a9597b)
Thanks [@mmaietta](https://github.com/mmaietta)! - chore: remove
deprecated fields from `winOptions` and `macOptions`. (For `winOptions`
signing configuration, it has been moved to `win.signtoolOptions` in
order to support `azureOptions` as a separate field and avoid bloating
`win` configuration object. For `macOptions`, notarize options has been
deprecated in favor of env vars for quite some time. Env vars are much
more secure)
-
[#8572](#8572)
[`0dbe357a`](0dbe357)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: allowing
additional entries in .desktop file, such as `[Desktop Actions
<actionName>]`. Requires changing configuration `desktop` property to
object to be more extensible in the future
-
[#8562](#8562)
[`b8185d48`](b8185d4)
Thanks [@beyondkmp](https://github.com/beyondkmp)! - support including
node_modules in other subdirectories

### Minor Changes

-
[#8787](#8787)
[`cdf18d9a`](cdf18d9)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: add `pwsh`
detection to enable azure trusted signing within docker image
-
[#8711](#8711)
[`6f0fb8e4`](6f0fb8e)
Thanks [@hrueger](https://github.com/hrueger)! - Add `host` property to
support self-hosted Keygen instances
-
[#8636](#8636)
[`88cc0b06`](88cc0b0)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: add support for
AppArmor with template profile and configuration property
-
[#8609](#8609)
[`d672b04b`](d672b04)
Thanks [@iongion](https://github.com/iongion)! - feat: support
completely custom AppxManifest.xml
-
[#8607](#8607)
[`f123628c`](f123628)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: allow disabling
of building a universal windows installer
-
[#8588](#8588)
[`8434e10d`](8434e10)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: adding
integration with @electron/fuses
-
[#8570](#8570)
[`c8484305`](c848430)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: migrate to
official `electron/asar` packaging
-
[#8525](#8525)
[`13f55a3e`](13f55a3)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: migrate
`electronDist` to be an electron-builder `Hook`
-
[#8394](#8394)
[`ae9221d9`](ae9221d)
Thanks [@xyloflake](https://github.com/xyloflake)! - feat: Implement
autoupdates for pacman
-
[#8741](#8741)
[`eacbbf59`](eacbbf5)
Thanks [@0xlau](https://github.com/0xlau)! - Add `forcePathStyle` option
to S3Options

### Patch Changes
-
[#8575](#8575)
[`dfa35c32`](dfa35c3)
Thanks [@doctolivier](https://github.com/doctolivier)! - chore(deps):
update @electron/rebuild to v3.7.0
-
[#8576](#8576)
[`3eab7143`](3eab714)
Thanks [@beyondkmp](https://github.com/beyondkmp)! - fix: packages in
the workspace not being under node_modules
-
[#8577](#8577)
[`e9eef0c1`](e9eef0c)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: add additional
default exclusions to copy logic
-
[#8596](#8596)
[`e0b0e351`](e0b0e35)
Thanks [@mmaietta](https://github.com/mmaietta)! - chore: refactor files
for publishing to electron-publish
-
[#8601](#8601)
[`215fc36b`](215fc36)
Thanks [@mmaietta](https://github.com/mmaietta)! - Revert "fix(win): use
appInfo description as primary entry for FileDescription" to resolve
[#8599](#8599)
-
[#8603](#8603)
[`712a8bce`](712a8bc)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: checking
relative path without separator as that doesn't work on Windows
-
[#8604](#8604)
[`d4ea0d99`](d4ea0d9)
Thanks [@beyondkmp](https://github.com/beyondkmp)! - chore(deps): update
app-builder-bin to 5.0.0-alpha.11
-
[#8606](#8606)
[`a0e635c1`](a0e635c)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: add quotes to
surround file path during azure signing to handle files with spaces
-
[#8627](#8627)
[`2a3195d9`](2a3195d)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: add rfc3161
timestamp entry as default for azure signing to resolve Windows Defender
alert
-
[#8631](#8631)
[`dcd91a1f`](dcd91a1)
Thanks [@olivereisenhut](https://github.com/olivereisenhut)! - fix:
Remove path from published binaries
-
[#8632](#8632)
[`645e2abd`](645e2ab)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: only sign
concurrently when using local signtool. azure can't be in parallel due
to resources being locked during usage
-
[#8637](#8637)
[`667ab2f8`](667ab2f)
Thanks [@mmaietta](https://github.com/mmaietta)! - chore: migrate
default recommends and default depends for fpm from app-builder-bin to
JS code
-
[#8645](#8645)
[`f4d40f91`](f4d40f9)
Thanks [@beyondkmp](https://github.com/beyondkmp)! - fix: smart unpack
for local module with dll
-
[#8653](#8653)
[`796e1a07`](796e1a0)
Thanks [@IsaacAderogba](https://github.com/IsaacAderogba)! - fix:
cscIKeyPassword must support empty string arguments
-
[#8654](#8654)
[`9e11358f`](9e11358)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: check
ResolvedFileSet src when verifying symlinks to be within project
directory
-
[#8661](#8661)
[`6a294c97`](6a294c9)
Thanks [@t3chguy](https://github.com/t3chguy)! - chore: remove stale
handler for `extend-info` in electronMac plist creation
-
[#8689](#8689)
[`1d7f87c1`](1d7f87c)
Thanks [@Lemonexe](https://github.com/Lemonexe)! - fix(win): corrupt
asar integrity file path on crossplatform build
-
[#8693](#8693)
[`6a6bed46`](6a6bed4)
Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps):
update dependency cross-spawn to v7.0.5 [security]
-
[#8714](#8714)
[`66334502`](6633450)
Thanks [@kttmv](https://github.com/kttmv)! - chore: Remove informal
Russian messages in the NSIS installer
-
[#8715](#8715)
[`4c394d54`](4c394d5)
Thanks [@beyondkmp](https://github.com/beyondkmp)! - fix: does not work
with NPM workspaces
-
[#8717](#8717)
[`9381513d`](9381513)
Thanks [@beyondkmp](https://github.com/beyondkmp)! - fix(deps): update
dependency eslint to v9.16.0 [security]
-
[#8783](#8783)
[`a5558e33`](a5558e3)
Thanks [@mmaietta](https://github.com/mmaietta)! - chore(deps): upgrade
cross spawn 7.0.6
-
[#8805](#8805)
[`c6d6b6e5`](c6d6b6e)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: ASAR files in
extraResources are not included in integrity calculations
-
[`a1ee0419`](a1ee041)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: use FileCopier
for copying files and queue creation of symlinks

## electron-updater 6.4.0

### Minor Changes

-
[#8711](#8711)
[`6f0fb8e4`](6f0fb8e)
Thanks [@hrueger](https://github.com/hrueger)! - Add `host` property to
support self-hosted Keygen instances
-
[#8633](#8633)
[`96f5c3eb`](96f5c3e)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat(updater): allow
usage of `autoRunAppAfterInstall` on mac updater
-
[#8394](#8394)
[`ae9221d9`](ae9221d)
Thanks [@xyloflake](https://github.com/xyloflake)! - feat: Implement
autoupdates for pacman

### Patch Changes

-
[#8802](#8802)
[`4a68fd2d`](4a68fd2)
Thanks [@erijo](https://github.com/erijo)! - fix(linux): AppImage update
fails when filename contains spaces
-
[#8623](#8623)
[`cfa67c01`](cfa67c0)
Thanks [@DamonYu6](https://github.com/DamonYu6)! - fix: copyFileSync
operation will block the main thread
-
[#8695](#8695)
[`819eff7b`](819eff7)
Thanks [@peter-sanderson](https://github.com/peter-sanderson)! - fix:
respect `disableDifferentialDownload` flag for AppImage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants