【问题标题】:Packaging electron app for windows with jenkins and electron-packager in Linux在 Linux 中使用 jenkins 和 electron-packager 为 windows 打包电子应用程序
【发布时间】:2019-07-29 12:59:34
【问题描述】:

我正在尝试使用 Jenkins 自动构建电子应用程序。在我直接在 Windows PC 上使用电子打包程序之前(因为该应用程序旨在在 Windows 中使用)但现在我想使用 Linux 环境进行构建过程(例如 Ubuntu)我收到以下错误:

15:55:32 Packaging app for platform win32 ia32 using electron v1.8.7
15:55:36 WARNING: Found 'electron' but not as a devDependency, pruning anyway
15:56:21 Could not find "wine" on your system.
15:56:21 
15:56:21 Wine is required to use the appCopyright, appVersion, buildVersion, icon, and 
15:56:21 win32metadata parameters for Windows targets.
15:56:21 
15:56:21 Make sure that the "wine" executable is in your PATH.
15:56:21 
15:56:21 See https://github.com/electron-userland/electron-packager#building-windows-apps-from-non-windows-platforms for details.

旧的打包脚本(在 package.json 中定义)

electron-packager . test-app --overwrite --asar --platform=win32 --arch=ia32 --prune=true --out=release-builds

按照建议,我为打包创建了一个 gulp 脚本:

var opts = {
    name: pkg.name,
    platform: 'win32',
    arch: 'ia32',                           // ia32, x64 or all
    dir: './',                       // source location of app
    out: './edist/',              // destination location for app os/native binaries
    asar: true, // compress project/modules into an asar blob but don't use asar to pack the native compiled modules
    overwrite: true,
    prune: true,
    electronVersion: electronVersion ,       // Tell the packager what version of electron to build with
    appCopyright: pkg.copyright,            // copyright info
    appVersion: pkg.version,         // The version of the application we are building
    win32metadata: {                        // Windows Only config data
        CompanyName: pkg.authors,
        ProductName: pkg.name,
        FileDescription: pkg.description,
        OriginalFilename: pkg.name + '.exe'
    }
};

    gulp.task('build:electron', done =>  {

        console.log('Launching task to package binaries for ' + opts.name + ' v' + opts['appVersion']);

    packager(opts).then(appPaths => {
            console.log(' PackagerDone(). appPaths :  ', appPaths);

        var zippedPromises = appPaths.map(function (appPath) {
            console.log('Preparing pipe for zip ', appPath + ".zip");
            return zipFolder(appPath, appPath + ".zip");
        });

        Promise.all(zippedPromises).then(function () {
            console.log(' Zip file created.');        
        }).catch(function (error) {
            console.error(error, error.stack);
        });    

        done();
    });

    });

这同样适用于 Windows,但在 Ubuntu 上返回相同的错误。 (zipFolder将release文件夹转换为zip文件,只是我写的一个额外的函数)

我的问题是,是否可以根本不安装 wine 并使其工作?

【问题讨论】:

  • 您能出示您的包装代码吗?
  • 你的意思是我必须在 package.json 中为电子打包器定义的那个吗?我加了。

标签: windows ubuntu jenkins electron wine


【解决方案1】:

简短的回答是,当您尝试在构建脚本/Jenkins 环境中运行时,您可以更有效地使用electron-packager API。至少,这是我发现的。这使您可以更简洁地配置和参数化您的建筑。

在我们的例子中,我们将 electron-packager 包装在一个漂亮的 gulp 脚本中,以使其构建良好并且可以从 Jenkins 很好地调用。

此链接可能会让您了解如何进行操作以及可以很好使用的标准组件:

Example of Building an Electron app with electron-packager

【讨论】:

  • 我安装了 gulp 并创建了一个脚本,该脚本是从 linux env (Ubuntu) 中的命令行调用的,但由于未安装“wine”,我仍然遇到问题。
【解决方案2】:

最后,解决方案可能是直接在 Windows 环境中运行构建脚本,或者在 Linux 下安装 Wine(詹金斯“生活”的地方)。 @Kim Gentes 的想法帮助我思考,特别是以更好、更易读的方式组织构建脚本。

【讨论】:

    猜你喜欢
    • 2017-05-31
    • 2017-01-29
    • 2015-09-17
    • 2016-08-24
    • 2016-05-05
    • 2021-01-05
    • 2020-01-04
    • 2021-10-14
    • 2021-03-03
    相关资源
    最近更新 更多