我正在尝试使用Jenkins自动构建电子应用程序。在我直接在Windows PC上使用electronic-packager进行操作之前(因为该应用程序打算在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文件,这只是我编写的一个附加功能)
我的问题是,有可能根本不安装wine并使其工作吗?
答案 0 :(得分:0)
简短的答案是,当您尝试在构建脚本/ Jenkins环境中运行时,可以更有效地使用electron-packager
API。至少,这是我发现的。这使您可以更简洁地配置和参数化建筑物。
在我们的案例中,我们将electron-packager
封装在一个不错的gulp
脚本中,以使其能够很好地构建并可以从Jenkins很好地调用。
此链接可能使您了解如何使用它以及很好用的标准组件:
答案 1 :(得分:0)
最后,解决方案可以是,直接在Windows环境中运行构建脚本,或者在Linux下安装Wine(Jenkins曾在这里生活)。 @Kim Gentes的想法帮助我思考,特别是以一种更好,更易读的方式来组织构建脚本。