electron-wix-msi
electron-wix-msi copied to clipboard
How to guide?
Wanted to try out this project but could not find usage steps
Same here
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?
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.
Did anyone figure out how to run this?
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.
Any update on a guide?
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
`
@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.
Probably Babel is not an option. I used TypeScript and got a working installation.
- Install Wix Toolkit as mentioned in docs
- Add path as mentioned by @MillerLoren
- 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.
- 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",
]
}
}
- Check both files in the folder build
- Add
npm runcommand 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.
@joergkrause this should definitely be in the main readme
@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?
@jerryheir I'm in the same situation, my fix was to get a VM.
Oh okay. Thanks
On Fri, Jun 26, 2020, 6:25 PM James Hurliman [email protected] wrote:
@jerryheir https://github.com/jerryheir I'm in the same situation, my fix was to get a VM.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/felixrieseberg/electron-wix-msi/issues/1#issuecomment-650300944, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHDHZJ7YMM7K5MPAMIQKFMTRYTKX3ANCNFSM4EEH5NTQ .
how can I fix this in github actions?
@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.
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?
I've installed
electron-wix-msias a dev dependency and when I try to make msi file by runningnpm run makeI 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.exeI then installed
wix311.exefrom the wix repo and added the path towardcandleand '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
CandleorLighteventhough 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.
How to install these exe in github actions?
@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.
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?
@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
@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.
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
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.