使用 Blazor Server App 的 Electron 应用程序的 MSI 安装程序

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

由于我是电子和 blazor 的新手,我不确定如何为电子应用程序创建 MSI 安装程序

我已经在 Visual Studio 2022 中使用 .NET 6.0 从基本的 Hello World Blazor 服务器应用程序创建了一个 Electron 应用程序。现在我计划为其创建一个 MSI 安装程序。

我尝试使用电子生成器创建它,但失败了。我可以使用 electronize build 命令创建一个 exe,但就我而言这还不够。

我收到一条错误,指出 main.js 无法访问。后来我手动创建了 main.js 文件,现在它要求指向 index.html 页面。正如我上面提到的,我在 Blazor 服务器应用程序中找不到任何此类文件。

非常感谢您的指导!

提前致谢。

package.json

{
  "build": {
    "appId": "com.SecondElectronApp.app",
    "win": {
      "target": "msi",
      "icon": "icon.ico"
    }
  },
  "name": "second-electron-app",
  "description": "Second Electron Application",
  "author": "XXX",
  "singleInstance": false,
  "environment": "Production",
  "version": "1.0.0",
  "devDependencies": {
    "electron": "^28.0.0",
    "electron-builder": "^24.9.1"
  },
  "scripts": {
    "start": "electron .",
    "dist": "electron-builder"
  }
}

电子.manifest.json

{
  "executable": "SecondElectronApp",
  "splashscreen": {
    "imageFile": ""
  },
  "name": "SecondElectronApp",
  "author": "",
  "singleInstance": false,
  "environment": "Production",
  "build": {
    "appId": "com.SecondElectronApp.app",
    "productName": "SecondElectronApp",
    "copyright": "Copyright © 2020",
    "buildVersion": "1.0.0",
    "compression": "maximum",
    "directories": {
      "output": "../../../bin/Desktop"
    },
    "extraResources": [
      {
        "from": "./bin",
        "to": "bin",
        "filter": [ "**/*" ]
      }
    ],
    "files": [
      {
        "from": "./ElectronHostHook/node_modules",
        "to": "ElectronHostHook/node_modules",
        "filter": [ "**/*" ]
      },
      "**/*"
    ]
  }
}

我尝试过使用电子构建器,但收到以下错误。

Application entry file "index.js" in the "C:\Users\niyas.pk\source\repos\ElectronApplications\SecondElectronApp\dist\win-unpacked\resources\app.asar" does not exist. Seems like a wrong configuration.
electron windows-installer blazor-server-side electron-builder
1个回答
0
投票

检查你的

app.asar
文件的内容(使用7-zip和Asar7z插件),你的文件在那里吗?它与您的
main
节点的目标路径匹配吗?

注意 app.asar 文件的内容应该是编译后的 JS 文件,而不是源(TS)文件,因此如果您打包源文件,那么您很可能打包了错误的文件夹。

我附上了几周前在电子上设置我的第一个应用程序时遇到的问题的旧图片,我的问题,就像我所说的那样,是我正在打包源代码;基本上,您想要打包 dist 或输出目录,而不是从 src 目录打包

old similar error

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