electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.41k stars 506 forks source link

Shortcuts poiting to the worng exe file, and so, not starting application #2163

Open LeonardoRick opened 3 years ago

LeonardoRick commented 3 years ago

Preflight Checklist

Issue Details

Actual Behavior

The start menu and desktop created shortcuts are poiting to $HOME/AppData/local/mypackage/mypackage.exe and the working .exe file is in $HOME/AppData/local/mypackage/app-0.0.0/mypackage.exe

Expected Behavior

The created shortcuts should point to the right .exe and start the aplication properly. If I click on the right file, the aplication starts just fine.

To Reproduce

main.js:

if(require('electron-squirrel-startup')) return;
const { app, BrowserWindow, globalShortcut } = require('electron');
const nativeImage = require('electron').nativeImage;

let win;
const image = nativeImage.createFromPath(__dirname + 'favicon.ico');
image.setTemplateImage(true);
// this should be placed at top of main.js to handle seup events quickly.
// squirrel event handled and app will exit in 1000ms, so don't do anything else
// if(handleSquirrelEvent()) return;

function createWindow() {
    win = new BrowserWindow({
        width: 1200,
        height: 800,
        backgroundColor: '#ffffff',
        icon: image,
        webPreferences: {
            nodeIntegration: true
        }
    });

    win.loadURL(`file://${__dirname}/dist/iq-web-bot/index.html`);

    // uncomment below to open the DevTools
    // win.webContents.openDevTools()

    win.on('closed', function() {
        win = null;
    });
}

// create window on electron initialization
app.on('ready', function() {
    createWindow();

    globalShortcut.register('f5', function() {
        console.log('f5 is pressed')
        win.reload()
    })
    globalShortcut.register('CommandOrControl+R', function() {
        console.log('CommandOrControl+R is pressed')
        win.reload()
    })
})

// quit when all windows are closed
app.on('window-all-closed', function () {

    // on macOS specific close process
    if (process.platform !== 'darwin') {
        app.quit();
    }
});

app.on('activate', function() {
    if (win == null) {
        createWindow();
    }
});

resumed package.json

{
  "name": "iq-web-bot",
  "productName": "iq-web-bot",
  "description": "Web and Native Bot for IQ Option awesome investments and profit.",
  "version": "0.0.0",
  "main": "main.js",
  "scripts": {
    "ng": "ng",
    "build-forge": "ng build --configuration local",
    "package": "electron-forge package",
    "make": "electron-forge make",
    "make-linux": "electron-forge make --platform linux --targets @electron-forge/maker-deb",
    "make-win": "electron-forge make --platform win32 --targets @electron-forge/maker-squirrel",
    "forge-linux": "npm run build-forge && npm run make-linux",
    "forge-win": "npm run build-forge && npm run make-win",
  },
  "private": true,
  "dependencies": {
    "buffer": "^5.6.0",
    "child_process": "^1.0.2",
    "electron-squirrel-startup": "^1.0.0",
    "firebase": "^7.19.1",
    "lodash": "^4.17.20",
    "moment": "^2.27.0",
    "ngx-mask": "^10.0.1",
    "ngx-socket-io": "^3.2.0",
    "os": "^0.1.1",
    "path": "^0.12.7",
    "rxjs": "^6.6.3",
    "source-map-loader": "^1.0.1",
    "tslib": "^2.0.0",
    "tweetnacl": "^1.0.3",
    "tweetnacl-util": "^0.15.1",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@electron-forge/cli": "^6.0.0-beta.54",
    "@electron-forge/maker-deb": "^6.0.0-beta.54",
    "@electron-forge/maker-dmg": "^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",
    "@tailwindcss/custom-forms": "^0.2.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.12.54",
    "electron": "^11.2.3",
    "electron-packager": "^15.2.0",
    "electron-winstaller": "^4.0.2",
  },
  "config": {
    "forge": "./forge.config.js"
  }
}

config.js

const path = require('path');

module.exports = {
    packagerConfig: {},
    makers: [
      {
        name: '@electron-forge/maker-squirrel',
        config: {
          iconUrl: 'https://iqwebbot.com/favicon.ico',
          setupIcon: path.join(__dirname, 'src', 'assets', 'logo-blue.ico'),
          name: 'iq-web-bot',
          authors: 'Leonardo Rick',
        }
      },
      {
        name: '@electron-forge/maker-zip',
        platforms: ['darwin']
      },
      {
        name: '@electron-forge/maker-deb',
        config: {
          icon: './dist/iq-web-bot/assets/logo-gray.png'
        }
      },
      {
        name: '@electron-forge/maker-rpm',
        config: {}
      },
      {
        name: '@electron-forge/maker-dmg',
        config: {
          background: './assets/dmg-background.png',
          format: 'ULFO'
        }
      }
    ]
  }

this is the level of the .exe pointed by the shortcuts image

this is lthe level it should be poiting:

image

knownasilya commented 3 years ago

Seeing this as well, an ideas? Related issue? https://github.com/electron/windows-installer/issues/238

Kholmukhammadov commented 1 year ago

Thi issue opened 2 years ago. Is there any solution to solve this problem?

joelnet commented 1 year ago

I was experiencing this problem and my solution was found here https://github.com/electron/windows-installer/issues/238#issuecomment-1016054367

I changed my version in my package.json from '0.0.0' to '0.0.1' and it now functions correctly.

Best of luck!