将APPX封装在APPXBUNDLE中

时间:2019-03-21 09:08:47

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

我目前在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文件。我是否可以仅创建一个包含电子.appxbundle文件的.appx,然后将该应用提交到Windows应用商店?

谢谢

3 个答案:

答案 0 :(得分:1)

是的,可以,这是MSFT的分步文章,显示了如何为现有msix / appx程序包生成MSIX捆绑软件。

答案 1 :(得分:1)

这是我对自己问题的答应。

正如我已经提到的那样,您必须坚持最初将应用程序提交给Microsoft App Store的捆绑软件格式。 .appxbundle就我而言。

我正在使用electron-builder,它吐出.appx,然后我用.appxbundle捆绑成afterAllArtifactBuildHook

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

注意:这是针对macOS的,适用于Windows 10的功能Parallels桌面安装,已设置为生成.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);
    }
}

答案 2 :(得分:0)

Electron Apps可以为Windows应用商店编译。微软开发了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了解详细的步骤和要求。

相关问题