【问题标题】:Package APPX in APPXBUNDLE在 APPXBUNDLE 中打包 APPX
【发布时间】:2020-08-11 17:00:32
【问题描述】:

我目前在 Windows 应用商店中提交了一个 UWP 应用,现在我想发布更新。此更新基于 Electron,因此不再是 UWP 应用。

我只是想将 Electron 应用程序提交到 Windows 应用商店,但我收到此错误消息: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.

Electron 应用与electron-builder 打包在一起,生成的文件是appx 文件。之前我使用 Visual Studio 打包应用程序,生成的文件是 appxbundle

根据此错误消息,我必须提交 .msixbundle.appxbundle 文件。我可以只创建一个包含 Electron .appx 文件的 .appxbundle,然后将应用程序提交到 Windows 应用商店吗?

谢谢

【问题讨论】:

    标签: windows-store-apps electron electron-builder desktop-bridge


    【解决方案1】:

    是的,您可以,这是来自 MSFT 的分步文章,展示了如何为现有的 msix/appx 包生成 MSIX 包。

    【讨论】:

    • 我正在关注文档,但存在一些不一致之处。看起来/p 选项不受支持,我需要Packaging Layout File。有什么建议吗?
    • 对不起,也不知道所有细节。也许对 MSFT 的文章发表评论,他们会回复你?这里还有一个关于包布局的线程,可能会为您提供更多详细信息:techcommunity.microsoft.com/t5/MSIX-Packaging-and-Tools/…
    【解决方案2】:

    这是对我自己问题的承诺答案。

    正如我已经提到的,您必须坚持最初将应用提交到 Microsoft App Store 的捆绑格式。所以.appxbundle就我而言。

    我正在使用electron-builder,它会吐出一个.appx,然后我使用afterAllArtifactBuildHook将它捆绑到一个.appxbundle

    这是位于我的电子项目的build/hooks 文件夹中的afterAllArtifactBuildHook.js。它会自动利用来自electron-builder 的已缓存的winCodeSign 工具,因此它可以确保所有内容都匹配。

    注意:这适用于 macOS 和功能性 Parallels 桌面安装,Windows 10 已设置为构建 .appx 文件

    var path = require("path"),
        fs = require("fs"),
        glob = require("glob"),
        childProcess = require('child_process');
    
    exports.default = function(buildResult) {
        buildResult.artifactPaths.forEach(function(appxPath) {
            if (appxPath.endsWith(".appx")) {
                convertAppx2AppxBundle(appxPath);
            }
        });
    };
    
    /**
     * Converts a Unix Path to a Windows conforming path by replacing any "/" with "\"
     * @return {string}
     */
    String.prototype.windowsify = function windowsify() {
        return this.replace(/\//g, "\\");
    }
    
    /**
     * Converts the given appx to an appxbundle used for Windows Store submission
     * @note This function utalizes the parallels desktop tool "prlctl" to execute windows commands via macOS
     * @param appxPath
     */
    function convertAppx2AppxBundle(appxPath) {
        try {
            console.log("Converting Appx to Appxbundle...")
            // We'll use electron-builder's winCodeSign tools which are conveniently already available in the following dir
            var electronBuilderDir = path.join(process.env.HOME, "Library/Caches/electron-builder"), // Don't use "~" it will just not work, trust me...
                // Will use the first matching windowsCodeSigning path as we may have multiple versions installed
                makeAppX = glob.sync(path.join(electronBuilderDir, "winCodeSign", "winCodeSign-*", "windows-10", "x64", "makeappx.exe"))[0],
                appxBundleMapFile = // This file is required by the makeappx.exe to generate the appxbundle
                    '[Files]\n' +
                    '"\\\\Mac\\AllFiles' + appxPath.replace(/\//g, "\\") + '"\t\t"Loxone.appx"';
    
            // Save the generated AppxBundle.map file to the filesystem to make it available for the Windows VM
            fs.writeFileSync(path.join(__dirname, "..", "AppxBundle.map"), appxBundleMapFile, { flag: "w" });
    
            var prlctlArgs = [
                'exec',
                '"Windows 10"', // the name of the specific Windows VM
                '--current-user', // We want to execute the following command with the current user
                // From this point on its the default Windows CLI command for converting an .appx to an .apppxbundle
                // Its important to know that these parts must conform to the Windows style, hence the windowsify function
                // We also need to use double quotation for the network shares due to how childProcess.execSync works...
                '"\\\\\\Mac\\AllFiles' + makeAppX.windowsify() + '"',
                'bundle',
                '/f',
                '"\\\\\\Mac\\AllFiles' + (__dirname.replace("/hooks", "") + "/AppxBundle.map").windowsify() + '"',
                '/p',
                '"\\\\\\Mac\\AllFiles' + appxPath.windowsify() + 'bundle"',
                '/o'
            ];
            // Now just execute the command to convert the appx to an appxbundle
            childProcess.execSync('prlctl ' + prlctlArgs.join(" "), { stdio: 'inherit' });
            console.log("Done converting Appx to Appxbundle");
        } catch (e) {
            console.warn("Couldn't convert appx two appxbundle!");
            console.error(e);
        }
    }
    

    【讨论】:

      【解决方案3】:

      可以为 Windows 应用商店编译电子应用程序。 Microsoft 开发了a tool that compiles Electron apps as .appx packages,使开发人员能够使用新应用程序模型中的一些优点。新的 .appx 格式不仅支持许多新的强大 API,例如 Cortana 或推送通知,而且通过 Windows 应用商店,还简化了安装和更新。具体步骤和要求可以参考Electron Documentation: Windows Store GuideMicrosoft Blog Compiling Electron Apps for the Windows Store

      【讨论】:

      • 我和一位微软支持员工聊天,他把我推向了正确的方向。创建.appx 文件没有任何问题,但将其提交到Windows 应用商店。如果您之前以捆绑形式提交申请,您似乎需要坚持使用捆绑形式。这种行为在某种程度上没有得到足够好的记录。稍后我将通过详细指南回答我的问题。
      猜你喜欢
      • 1970-01-01
      • 2016-04-22
      • 1970-01-01
      • 2021-08-02
      • 1970-01-01
      • 1970-01-01
      • 2017-07-16
      • 2018-09-13
      • 1970-01-01
      相关资源
      最近更新 更多