windows - 在 Linux 中使用 jenkins 和 electron-packager 为 windows 打包 Electron 应用程序

标签 windows ubuntu jenkins electron wine

我正在尝试使用 Jenkins 自动构建 Electron 应用程序。在我直接在 Windows PC 上使用 Electron 打包程序之前(因为该应用程序旨在在 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 文件,它只是我写的一个额外的功能)

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

最佳答案

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

在我们的例子中,我们包裹了 electron-packager在一个不错的gulp脚本使其构建良好并可以从 Jenkins 很好地调用。

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

Example of Building an Electron app with electron-packager

关于windows - 在 Linux 中使用 jenkins 和 electron-packager 为 windows 打包 Electron 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55047209/

相关文章:

python - 如何执行 shell 命令来填充 Jenkins 动态选择参数插件

jenkins - 如何在 Jenkins 管道中使用自定义 Dockerfile 名称?

windows - Windows 中的 msync 等效项

c# - 如何在 C# Windows 窗体中停止加载窗体

c++ - 如何在 C++ 中模拟按键

bash - "watch"如何处理串联命令?

windows - ImageList_Add 在由 pcAnywhere 控制的 PC 上返回 -1

file - 从 gvim 外部打开文件

linux - 尝试在 ubuntu ec2 实例上安装某些东西

git - SonarQube具有浅克隆警告,即使在Jenkins build上禁用了浅克隆