Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to guide? #1

Open
Ajeey opened this issue Nov 17, 2017 · 23 comments
Open

How to guide? #1

Ajeey opened this issue Nov 17, 2017 · 23 comments

Comments

@Ajeey
Copy link

Ajeey commented Nov 17, 2017

Wanted to try out this project but could not find usage steps

@ReynaldoBelfortUPRM
Copy link

Same here

@darkguy2008
Copy link

Same here, how are us expected to use this without an usage guide? What do I do with that code? should be in Gulp? normal js file? node? what?

@felixrieseberg
Copy link
Collaborator

Hey! I apologize if the existing README isn't good enough - the module was built without a CLI use case in mind, but we could certainly add one.

I'll see if I have time for that later this week.

@Chandher05
Copy link

Did anyone figure out how to run this?

@KyleMoser
Copy link

How do I use this with electron-forge? Or anything else? In particular, where does the code under the "Usage" section go? How do I run it?

It says creating an installer is a three step process, but then goes on to only list a single step (which is just the Usage section code itself) and doesn't say what to do with that code.

@AlmondBro
Copy link

Any update on a guide?

@AlmondBro
Copy link

AlmondBro commented Aug 14, 2018

I figured we have to run the file in node, so I used the native Node require() since the import statement cannot be used without Babel, due to it being an ES6 JS feature.

//import { MSICreator } from 'electron-wix-msi';
var MSICreator = require("electron-wix-msi").MSICreator;

async function start() {
    
// Step 1: Instantiate the MSICreator
const msiCreator = new MSICreator({
    appDirectory: './dist/win-unpacked/',
    description: 'My amazing Kitten simulator',
    exe: 'kittens',
    name: 'Kittens',
    manufacturer: 'Kitten Technologies',
    version: '1.1.2',
    outputDirectory: './dist/win-unpacked/'
  });
  
  // Step 2: Create a .wxs template file
  await msiCreator.create();
  
  // Step 3: Compile the template to a .msi file
  await msiCreator.compile();
}

start();

Upon running the code, even with the Toolkit and this node module installed, i get this error:

$ node createInstaller.js
'light' is not recognized as an internal or external command,
operable program or batch file.
'candle' is not recognized as an internal or external command,
operable program or batch file.
It appears that electron-wix-msi cannot find candle.exe or light.exe.
Please consult the readme at https://github.com/felixrieseberg/electron-wix-msi
for information on how to install the Wix toolkit, which is required.

(node:4964) UnhandledPromiseRejectionWarning: Error: Could not find light.exe or candle.exe

`

@MillerLoren
Copy link

@JuanDavidLopez95 I was able to fix that problem by adding "C:\Program Files (x86)\WiX Toolset v3.11\bin" (with quotes) to my user variables and system variables for windows.

bitdisaster added a commit that referenced this issue Oct 2, 2018
@joergkrause
Copy link

joergkrause commented Feb 5, 2019

Probably Babel is not an option. I used TypeScript and got a working installation.

  1. Install Wix Toolkit as mentioned in docs
  2. Add path as mentioned by @MillerLoren
  3. Create installation file as make-msi.ts in folder build (just a suggestion, any path will do it):
import * as msi from 'electron-wix-msi';
import * as path from 'path';

// Step 1: Instantiate the MSICreator
const msiCreator = new msi.MSICreator({
	appDirectory: path.resolve('release/win-unpacked'), // result from electron-builder
	description: 'Some text',
	exe: 'MyExe',
	name: 'MyExe',
	manufacturer: 'Joerg Krause',
	version: '0.5.0',
	language: 1033,
	arch: 'x86',
	outputDirectory: path.resolve('release/msi/')
});

async function createMsi() {
	// Step 2: Create a .wxs template file
	await msiCreator.create();

	// Step 3: Compile the template to a .msi file
	await msiCreator.compile();
}
console.log('Invoke MSI Builder');
createMsi();

release/win-unpacked is the output from electron-builder.

  1. Add tsconfig.json with appropriate settings in same folder build:
{
  "compilerOptions": {
    "target": "es2015",
    "module": "commonjs",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "sourceMap": true,
    "lib": [
      "es2018",
      "es5",
      "dom"
    ],
    "experimentalDecorators": true,
    "noImplicitAny": false,
    "suppressImplicitAnyIndexErrors": true,
    "removeComments": false,
    "outDir": "js",
    "typeRoots": [
      "../node_modules/@types",
    ]
  }
}
  1. Check both files in the folder build
  2. Add npm run command like this to your package.json:
cd build && tsc && cd .. && node build/js/make-msi.js

My whole scripts block looks like this:

  "scripts": {
    "dev": "tsc win.ts --outDir ./dist && cross-env NODE_ENV=dev && npm run prev",
    "build": "rimraf ./dist && webpack",
    "start": "rimraf ./dist && webpack && electron .",
    "prev": "electron .",
    "test": "jest",
    "msi": "cd build && tsc && cd .. && node build/js/make-msi.js",
    "pack": "npm run build && rimraf ./release && build --dir && npm run msi",
    "dist": "build"
  }

This compiles the TypeScript into ES and executes the script with npm run msi. After a while you have your MSI.

Also, I had much more success using electron-builder instead of electron-packager.

@syonip
Copy link

syonip commented Feb 20, 2019

@joergkrause this should definitely be in the main readme

@jerryheir
Copy link

@JuanDavidLopez95 I was able to fix that problem by adding "C:\Program Files (x86)\WiX Toolset v3.11\bin" (with quotes) to my user variables and system variables for windows.

How can anyone do any of this with a macos?

@ajhurliman
Copy link

@jerryheir I'm in the same situation, my fix was to get a VM.

@jerryheir
Copy link

jerryheir commented Jun 26, 2020 via email

@a7madgamal
Copy link

how can I fix this in github actions?

@mistermicheels
Copy link

mistermicheels commented Aug 17, 2020

@a7madgamal I was able to get this working in GitHub Actions on windows-latest using the following step: run: echo "::add-path::${env:wix}bin". The command is a mix of GitHub Actions-specific syntax and PowerShell-specific syntax.

The effect of this command is that WiX Toolset (which is already installed) gets added to the PATH variable for later steps to use. Make sure to put this step before anything that tries to use electron-wix-msi. This should get rid of any errors regarding candle.exe or light.exe not being found.

@thefakhreddin
Copy link

I've installed electron-wix-msi as a dev dependency and when I try to make msi file by running npm run make I hit this error:

An unhandled error has occurred inside Forge:
An error occured while making for target: wix
Could not find light.exe or candle.exe
Error: Could not find light.exe or candle.exe

I then installed wix311.exe from the wix repo and added the path toward candle and 'light' in my PATH environment variable (C:\Program Files (x86)\WiX Toolset v3.11\bin)

But it still throws the same error. It cannot find Candle or Light eventhough they're both in the path.

Any ideas?

@thefakhreddin
Copy link

I've installed electron-wix-msi as a dev dependency and when I try to make msi file by running npm run make I hit this error:

An unhandled error has occurred inside Forge:
An error occured while making for target: wix
Could not find light.exe or candle.exe
Error: Could not find light.exe or candle.exe

I then installed wix311.exe from the wix repo and added the path toward candle and 'light' in my PATH environment variable (C:\Program Files (x86)\WiX Toolset v3.11\bin)

But it still throws the same error. It cannot find Candle or Light eventhough they're both in the path.

Any ideas?

The problem was the terminal that I was using. For some reason, it couldn't access the path. I switch to cmd and it worked.

@linonetwo
Copy link

How to install these exe in github actions?

@mistermicheels
Copy link

mistermicheels commented Apr 3, 2022

@linonetwo this is what worked for me: https://github.com/mistermicheels/current-task/blob/master/.github/workflows/build-for-windows.yml#L19

P.S.: The windows-latest image for GitHub Actions already has WiX Toolset installed, but you still need to add it to the PATH using the command that I linked or something similar.

@linonetwo
Copy link

linonetwo commented Apr 3, 2022

Many thanks, @mistermicheels , so npm i --save-dev electron-wix-msi is actually not needed.

But this path modification seems to remove npm from the path

'npm' is not recognized as an internal or external command,

What does | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 mean?

@mistermicheels
Copy link

mistermicheels commented Apr 3, 2022

@linonetwo you still need to install electron-wix-msi as a dev dependency for your project. But it cannot run without having WiX Toolset installed and available on the PATH. That last part is covered by my earlier comment.

| Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 is PowerShell syntax to write to the file at location GITHUB_PATH, which is how you can make changes to the PATH variable used by your actions. This is something specific to GitHub Actions, see also https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables.

For me, it doesn't seem to remove npm from the path. The workflow that I linked above is using npm after I add WiX Toolset to the path. However, it seems that GitHub recently changed the image that windows-latest refers to from Windows 2019 to Windows 2022. Maybe my command doesn't work well with the Windows 2022 image, not sure. You could try adding the -Append flag to the PowerShell command to see if that maybe helps. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/out-file?view=powershell-7.2

@mistermicheels
Copy link

mistermicheels commented Apr 3, 2022

@linonetwo I just tested my existing GitHub Actions workflow with windows-2022 and it still works, including the use of npm after I set the path variable. See here: https://github.com/mistermicheels/current-task/runs/5805767280?check_suite_focus=true

The best I can do is provide you my current workflow as a working example, I'm afraid you'll have to figure out the rest yourself.

@linonetwo
Copy link

linonetwo commented Apr 3, 2022

You could try adding the -Append flag to the PowerShell command to see if that maybe helps.

Thank you @mistermicheels you are very kind, and this works!

- name: Add msi to path
  run: echo "${env:wix}bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

My workflow

I also try to add some logging to the workflow run to try figuring out why

echo "${env:wix}bin"
> C:\Program Files (x86)\WiX Toolset v3.11\bin

On the left is the one using -Append and on the right is using echo "${env:path};${env:wix}bin", maybe too long of PATH causing the error finding npm? I don't know. At least we have an alternative now.

截屏2022-04-03 20 57 49

felixrieseberg pushed a commit that referenced this issue Mar 6, 2024
Added support for associating extensions with exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests