Search code examples
htmlelectronwixelectron-packager

Electron wix installer icon


Hello, my name is Alexie,

My question is how can I put an icon in electron wix installer from the configuration?

Here is the code:

const msiCreator = new MSICreator({
    appDirectory: APP_DIR,
    outputDirectory: OUT_DIR,

    // Configure metadata
    description: 'Optimum cuts',
    exe: 'HyperCut',
    name: 'HyperCut',
    manufacturer: 'Omifa',
    version: '1.0.0',

    // Configure installer User Interface
    ui: {
        enabled: true,
        chooseDirectory: true,
        images: {
            banner: __dirname + '\\ico\\logo.png',
            background: __dirname + '\\ico\\logo_m.jpg'
        }
    },
});

Solution

  • I am using Electron in an Angular app. The code I use for the icon is the next one:

    // Modules to control application life and create native browser window
    const { app, BrowserWindow } = require('electron')
    const path = require('path')
    
    // Keep a global reference of the window object, if you don't, the window will
    // be closed automatically when the JavaScript object is garbage collected.
    let mainWindow
    
    function createWindow() {
        // Create the browser window.
        mainWindow = new BrowserWindow({
            width: 2024,
            height: 1768,
            minWidth: 400,
            minHeight: 200,
            resizable: true,
            backgroundColor: '#222',
            center: true,
            autoHideMenuBar: true,
            icon: 'produccion.ico',
            label: 'FromScratch',
            title: '',
            webPreferences: {
                preload: path.join(__dirname, 'preload.js')
            }
        })
    
        // and load the index.html of the app.
        mainWindow.loadFile('Produccion/dist/index.html')
    
        mainWindow.maximize()
    
        // Open the DevTools.
        // mainWindow.webContents.openDevTools()
    
        // Emitted when the window is closed.
        mainWindow.on('closed', function() {
            // Dereference the window object, usually you would store windows
            // in an array if your app supports multi windows, this is the time
            // when you should delete the corresponding element.
            mainWindow = null
        })
    }
    
    // This method will be called when Electron has finished
    // initialization and is ready to create browser windows.
    // Some APIs can only be used after this event occurs.
    app.on('ready', createWindow)
    
    // Quit when all windows are closed.
    app.on('window-all-closed', function() {
        // On macOS it is common for applications and their menu bar
        // to stay active until the user quits explicitly with Cmd + Q
        if (process.platform !== 'darwin') app.quit()
    })
    
    app.on('activate', function() {
        // On macOS it's common to re-create a window in the app when the
        // dock icon is clicked and there are no other windows open.
        if (mainWindow === null) createWindow()
    })