如何在ubuntu中使用electron builder为windows构建电子应用程序

mwecs4sa  于 12个月前  发布在  Electron
关注(0)|答案(1)|浏览(128)

我已经创建了一个电子应用程序.使用电子构建器我在Linux中创建了appImage.我想在Linux中为Windows构建应用程序.但它抛出葡萄酒需要错误.请帮助解决这个问题.这是package.json

"name": "Gamer",
  "version": "1.0.0", 
  "main": "main.js",
  "repository": "https://github.com/XYX/GAME",
  "dependencies": {
    "@agm/core": "^1.0.0-beta.5",
  ...
    "electron-builder-squirrel-windows": "^22.1.0",
    "electron-packager": "^14.1.0",
    "electron-reload": "^1.5.0",
    "electron-store": "^5.1.0",
 },
  "devDependencies": {
   ...
    "electron": "^7.1.1",
    "electron-builder": "^22.1.0",
    "electron-prebuilt": "^1.4.13",
    "electron-updater": "^4.2.0",
  ...
  },
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "start:electron": "ng build --base-href ./ && electron .",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "electron": "electron .",
    "electron-build": "ng build --prod && electron .",
    "pack": "electron-builder --dir",
    "dist": "electron-builder",
    "build:Win": "electron-builder --win",
    "ship": "build",
    "electron-packager": "electron-packager ./ --all."
  },
  "peerDependencies": {
    "@angular/animations": "^7.2.15",
    "@angular/cdk": "^7.3.7",
    "@angular/material": "^7.3.7"
  },
  "author": "",
  "license": "ISC",
  "build": {
    "appId": "com.electron.coxGamer",
    "compression": "normal",
    "extends": null,
    "files": [
      "*.js",
      "build",
      "dist"
    ],
    "mac": {
      "target": "zip"
    },
    "linux": {
      "target": [
        "AppImage",
        "zip"
      ]
    },
    "win": {
      "target": "NSIS"
    },
    "publish": {
      "provider": "github",
      "repo": "https://github.com/XYX/GAME",
      "owner": "XYX"
    }
  }
}

字符串
甚至电子更新抛出错误dev-update.yml没有找到。也应用图标没有设置

const { app, BrowserWindow, Menu,ipcMain } = require('electron');
const path = require('path');
const url = require('url');
const { autoUpdater } = require("electron-updater");

Menu.setApplicationMenu(null);
let mainWindow;
const createWindow = () => {
  mainWindow = new BrowserWindow({
    width: 1200,
    height: 900
  });
  mainWindow.setMenuBarVisibility(false);
  mainWindow.loadURL(url.format({
    pathname: path.join(__dirname, 'dist', 'index.html'),
    protocol: 'file:',
    slashes: true
  })); 
  mainWindow.on('closed', () => {
    mainWindow = null;
  });

};

autoUpdater.on('update-downloaded', (info) => {
  win.webContents.send('updateReady')
});

app.on('ready', () => {
  createWindow();
  autoUpdater.checkForUpdates();
});
ipcMain.on("quitAndInstall", (event, arg) => {
  autoUpdater.quitAndInstall();
});

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin')
    app.quit();
});
app.on('activate', () => {
  if (mainWindow === null) {
    createWindow();
  }
});

hts6caw3

hts6caw31#

下面是我如何从mac/Linux构建windows应用程序的。也许这可以帮助你@Krazy。
首先,我使用的是电子构建器的Docker版本
然后,这里是步骤
1-在您的项目中安装electron builder dev

npm install electron-builder —save-dev

字符串
2-在package.json中将此添加到脚本中

"dist": "electron-builder"


3-启动Docker
4-在终端,运行

docker run --rm -ti \
 --env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
 --env ELECTRON_CACHE="/root/.cache/electron" \
 --env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
 -v ${PWD}:/project \
 -v ${PWD##*/}-node-modules:/project/node_modules \
 -v ~/.cache/electron:/root/.cache/electron \
 -v ~/.cache/electron-builder:/root/.cache/electron-builder \
 electronuserland/builder:wine


5-cd到您的项目中
6-类型

yarn && yarn dist -w

相关问题