NIYAZ
NIYAZ

Reputation: 1

MSI Installer for an Electron application using Blazor Server App

As I am new to electron and blazor, I am not sure how to create an MSI installer for an electron application

I have created an Electron application from a basic Hello World Blazor server app using .NET 6.0 in visual studio 2022. Now I am planning to create an MSI installer for the same.

I have tried to create it using electron-builder and it was a failure. I can able to create an exe using electronize build command, but in my case that is not enough.

I am getting an error stating that main.js is not accessible. Later I have created main.js file manually and now it is asking to point to the index.html page. As I mentioned above, I could not find any such file in a Blazor Server App.

Your guidance will be much appreciated !!

Thanks in advance.

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"
  }
}

electron.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": [ "**/*" ]
      },
      "**/*"
    ]
  }
}

I have tried with electron-builder and I am getting the below error.

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.

Upvotes: 0

Views: 112

Answers (1)

jo-cor
jo-cor

Reputation: 1

Check the content of your app.asar file (use 7-zip & Asar7z plug-in), is your file there? does it match the target path from your main node?

Note the content of the app.asar file should be the compiled JS files, not the source (TS) files, so if you're packaging source files then chances are you're packaging the incorrect folder.

I'm attaching an old picture of a problem I had some weeks ago when setting my first app on electron, my problem, like said, is that I was packaging source code; basically, you want to package the dist or output directory, not to pack from your src directory

old similar error

Upvotes: 0

Related Questions