无法从OpenSuse Leap 15.1使用electron-forge和electon-winstaller构建目标win32

lh80um4z  于 2023-09-28  发布在  Electron
关注(0)|答案(1)|浏览(115)

我想做一个可执行的电子应用程序。我在OpenSuse Leap 15.1主机平台(Linux)上进行开发。我正在尝试为win32构建,但它给了我以下错误:

2020-11-04 08:44:08> Unhandled exception: System.IO.FileNotFoundException: Could not load file or assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
File name: 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
  at Squirrel.Update.Program.main (System.String[] args) [0x00060] in <9e2ab352f8944769b3794933dd42e8f9>:0 
2020-11-04 08:45:20> Unhandled exception: System.IO.FileNotFoundException: Could not load file or assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
File name: 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
  at Squirrel.Update.Program.main (System.String[] args) [0x00060] in <9e2ab352f8944769b3794933dd42e8f9>:0

下面是我的package.json文件:

{
  "name": "mailer-boy",
  "version": "1.0.0",
  "description": "An email client for IMAP server",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "electron-forge start",
    "package": "electron-forge package",
    "make": "electron-forge make"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@electron-forge/cli": "^6.0.0-beta.54",
    "@electron-forge/maker-deb": "^6.0.0-beta.54",
    "@electron-forge/maker-rpm": "^6.0.0-beta.54",
    "@electron-forge/maker-squirrel": "^6.0.0-beta.54",
    "@electron-forge/maker-zip": "^6.0.0-beta.54",
    "electron": "^10.1.5",
    "electron-winstaller": "^4.0.1"
  },
  "dependencies": {
    "base64-stream": "^1.0.0",
    "electron-squirrel-startup": "^1.0.0",
    "html-to-text": "^6.0.0",
    "node-imap": "^0.9.6",
    "underscore": "^1.11.0"
  },
  "config": {
    "forge": {
      "packagerConfig": {},
      "makers": [
        {
          "name": "@electron-forge/maker-squirrel",
          "config": {
            "name": "mailer_boy"
          }
        },
        {
          "name": "@electron-forge/maker-zip",
          "platforms": [
            "darwin"
          ]
        },
        {
          "name": "@electron-forge/maker-deb",
          "config": {}
        },
        {
          "name": "@electron-forge/maker-rpm",
          "config": {}
        }
      ]
    }
  }
}

以下是我尝试的命令:

> npm run make --targets @electron-forge/maker-squirrel
> npm run make --platform linux --targets win32

上面的命令一直忽略目标,只是为Linux构建了一个应用程序(在添加deb和rpm包之后)。我也试过这个:
winstaller.js

const createWindowsInstaller = require('electron-winstaller').createWindowsInstaller
const path = require('path')

getInstallerConfig()
  .then(createWindowsInstaller)
  .catch((error) => {
    console.error(error.message || error)
    process.exit(1)
  })

function getInstallerConfig () {
  console.log('creating windows installer')
  const rootPath = path.join('./')
  const outPath = path.join(rootPath, 'out')

  return Promise.resolve({
    appDirectory: path.join(outPath, 'mailer-boy-linux-x64'),
    authors: 'Abrar H Galib',
    noMsi: true,
    outputDirectory: path.join(outPath, 'windows-installer'),
    exe: 'mailerboy.exe',
    setupExe: 'MailerboyInstaller.exe',
    
  });
}

用Node.js运行上面的代码会出现上面给出的错误。如何从我的平台上定位Win32?我是否缺少任何依赖项?我安装了dotnet-sdk,dotnet-runtime,但没有帮助。谢谢.

编辑

我最终使用了一个朋友的Windows笔记本电脑来构建Windows应用程序。有点疼。我非常想知道是否可以从Linux构建Windows和MacOS。如果没有,继续使用Electron会有些不方便(也是无用的)。

6qftjkof

6qftjkof1#

我也在macOS上构建一个跨平台的电子应用程序,我也面临着同样的问题,但经过研究,我发现了一种方法,我想与你分享,
到目前为止,我还没有看到任何从MacOS本身构建跨平台可分发的方法,它将通过使用此命令electron-forge make -- --platform win32抛出如下错误

解决方案:

但是还有一种替代解决方案可以尝试,那就是使用electron-builder
你可以在全局/本地安装electron-builder,也可以使用npx electron-builder,强烈推荐通过yarn安装,但我选择npm,你可以选择任何你喜欢的方式。
checkout Electron-Builder CLI选项的文档:https://www.electron.build/cli
您可以使用npx electron-builder -mwl构建跨平台,其中选项代表MacOS的m、Windows的w和Linux的l

更新v1:

您可以使用npm run make -- --platform制作跨平台应用程序,但首先您的Mac系统应安装monowine包,以便使应用程序针对特定平台。

相关问题