在Linux中使用jenkins和electronic-packager的Windows封装电子应用程序

问题描述 投票:0回答:1

我正在尝试使用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转换zip文件中的release文件夹,它只是我编写的一个额外函数)

我的问题是,是否可以根本不安装葡萄酒并使其有效?

windows ubuntu jenkins electron wine
1个回答
0
投票

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

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

此链接可能会让您了解如何使用它以及可以使用的标准组件:

Example of Building an Electron app with electron-packager

© www.soinside.com 2019 - 2024. All rights reserved.