Reputation: 313
I created electron-forge based app, and now i am trying to create installation wizard using their built-in lib called electron-wix-msi (@electron-forge/maker-wix). Overall installer is created, and it's working - however now I need to modify the installer, and I need help with two things.
Any magicians here that can make it work?
Upvotes: 1
Views: 1248
Reputation: 31
This is not the cleanest or most correct solution, but hopefully it can help others or put them on the path to make a better solution.
For the first issue, in my solution below I disabled the desktop shortcut completely if that will help. There could be a way to have a checkbox to enable/disable desktop shortcuts but I don't think its straightforward, you can create an issue on GitHub or you will probably have to fork electron-wix-msi installer and modify some of the logic, someone else smarter than me will have to help us.
For the second issue, I lowered the feature level of the update-feature so that its enabled or installed by default.
You can achieve what you want by modifying the xml templates that the electron-wix-msi installer use. I tried it and it worked. However, I am not entirely sure if this is the best way to achieve this.
In order to modify the templates, you will have to modify their values in the MSICreator which you can do by writing a callback to the beforeCreate hook in your forge.config.js. This is a snippet of what I did.
We need to modify only two wix templates, you can find all the templates here.
//.....
makers: [
{
name: '@electron-forge/maker-wix',
config: {
//...config stuff
features: {
autoLaunch: true,
autoUpdate: true,
},
ui: {
chooseDirectory: true,
},
beforeCreate: async (msiCreator) => {
msiCreator.wixTemplate = getTemplate('myWix', false);
msiCreator.updaterTemplate = getTemplate('myUpdateFeature', true);
console.info('msiCreator config', msiCreator);
}
}
},
]
//....
const getTemplate = (name, trimTrailingNewLine) => {
const content = fs.readFileSync(path.join(__dirname, `temp/${name}.xml`), 'utf-8');
if (trimTrailingNewLine) {
return content.replace(/[\r\n]+$/g, '');
} else {
return content;
}
};
Upvotes: 1