Error when trying to create installer of windows package


#1

Hi all. I am trying to package electron app using electron-packager.
Electron v1.8.6
Electron-Packager:v8.7.2
Electron-wininstaller:2.6.4

Here is my createinstaller.js which I have running after packaging to create installer

const createWindowsInstaller = require('electron-winstaller').createWindowsInstaller
const path = require('path')



getInstallerConfig()
    .then(createWindowsInstaller)
    .catch((error) => {
        console.error(error.message || error)
        process.exit(1)
    })

function getInstallerConfig() {
    console.log('creating windows installer')
    const rootPath = path.join('./')
    const outPath = path.join(rootPath, 'release-builds')

    return Promise.resolve({
        appDirectory: path.join(outPath, 'EvenDexWin32/'),
        authors: 'Even Foundation',
        noMsi: true,
        outputDirectory: path.join(outPath, 'windows-installer'),
        exe: 'even.exe',
        setupExe: 'EvenDex.exe',
        setupIcon: path.join(rootPath, 'system', 'icons', 'favicon.ico')
    })
}

Here is the error which I am getting
creating windows installer
Failed with exit code: 4294967295
Output:
Couldn’t open log file, trying new file: System.MethodAccessException: Attempt by method ‘Squirrel.Update.SetupLogLogger…ctor(Boolean)’ to access method ‘System.IO.StreamWriter…cto
r(System.IO.Stream, System.Text.Encoding, Int32, Boolean)’ failed.
at Squirrel.Update.SetupLogLogger…ctor(Boolean saveInTemp)
Couldn’t open log file, trying new file: System.MethodAccessException: Attempt by method ‘Squirrel.Update.SetupLogLogger…ctor(Boolean)’ to access method ‘System.IO.StreamWriter…cto
r(System.IO.Stream, System.Text.Encoding, Int32, Boolean)’ failed.
at Squirrel.Update.SetupLogLogger…ctor(Boolean saveInTemp)
Couldn’t open log file, trying new file: System.MethodAccessException: Attempt by method ‘Squirrel.Update.SetupLogLogger…ctor(Boolean)’ to access method ‘System.IO.StreamWriter…cto
r(System.IO.Stream, System.Text.Encoding, Int32, Boolean)’ failed.
at Squirrel.Update.SetupLogLogger…ctor(Boolean saveInTemp)
Couldn’t open log file, trying new file: System.MethodAccessException: Attempt by method ‘Squirrel.Update.SetupLogLogger…ctor(Boolean)’ to access method ‘System.IO.StreamWriter…cto
r(System.IO.Stream, System.Text.Encoding, Int32, Boolean)’ failed.
at Squirrel.Update.SetupLogLogger…ctor(Boolean saveInTemp)
Couldn’t open log file, trying new file: System.MethodAccessException: Attempt by method ‘Squirrel.Update.SetupLogLogger…ctor(Boolean)’ to access method ‘System.IO.StreamWriter…cto
r(System.IO.Stream, System.Text.Encoding, Int32, Boolean)’ failed.
at Squirrel.Update.SetupLogLogger…ctor(Boolean saveInTemp)
Couldn’t open log file, trying new file: System.MethodAccessException: Attempt by method ‘Squirrel.Update.SetupLogLogger…ctor(Boolean)’ to access method ‘System.IO.StreamWriter…cto
r(System.IO.Stream, System.Text.Encoding, Int32, Boolean)’ failed.
at Squirrel.Update.SetupLogLogger…ctor(Boolean saveInTemp)
Couldn’t open log file, trying new file: System.MethodAccessException: Attempt by method ‘Squirrel.Update.SetupLogLogger…ctor(Boolean)’ to access method ‘System.IO.StreamWriter…cto
r(System.IO.Stream, System.Text.Encoding, Int32, Boolean)’ failed.
at Squirrel.Update.SetupLogLogger…ctor(Boolean saveInTemp)
Couldn’t open log file, trying new file: System.MethodAccessException: Attempt by method ‘Squirrel.Update.SetupLogLogger…ctor(Boolean)’ to access method ‘System.IO.StreamWriter…cto
r(System.IO.Stream, System.Text.Encoding, Int32, Boolean)’ failed.
at Squirrel.Update.SetupLogLogger…ctor(Boolean saveInTemp)
Couldn’t open log file, trying new file: System.MethodAccessException: Attempt by method ‘Squirrel.Update.SetupLogLogger…ctor(Boolean)’ to access method ‘System.IO.StreamWriter…cto
r(System.IO.Stream, System.Text.Encoding, Int32, Boolean)’ failed.
at Squirrel.Update.SetupLogLogger…ctor(Boolean saveInTemp)
Couldn’t open log file, trying new file: System.MethodAccessException: Attempt by method ‘Squirrel.Update.SetupLogLogger…ctor(Boolean)’ to access method ‘System.IO.StreamWriter…cto
r(System.IO.Stream, System.Text.Encoding, Int32, Boolean)’ failed.
at Squirrel.Update.SetupLogLogger…ctor(Boolean saveInTemp)
2018-05-08 00:44:22> Program: Starting Squirrel Updater: --releasify C:\Users\user\AppData\Local\Temp\si-11848-5792-yqf9jx.s6spr\EvenDex.0.1.0.nupkg --releaseDir C:\Users\user\Deskto
p\even-prototype\release-builds\windows-installer --loadingGif C:\Users\user\Desktop\even-prototype\node_modules\electron-winstaller\resources\install-spinner.gif --setupIcon C:\User
s\user\Desktop\even-prototype\system\icons\favicon.ico --no-msi
2018-05-08 00:44:22> Program: Bootstrapper EXE found at:C:\Users\user\Desktop\even-prototype\node_modules\electron-winstaller\vendor\Setup.exe
2018-05-08 00:44:22> Program: Creating release package: C:\Users\user\Desktop\even-prototype\release-builds\windows-installer\EvenDex.0.1.0.nupkg
2018-05-08 00:44:23> Unhandled exception: System.MissingMethodException: Method not found: ‘Int32 System.Environment.get_CurrentManagedThreadId()’.
at NuGet.ManifestMetadata.d__108…ctor(Int32 <>1__state)
at NuGet.ManifestMetadata.Validate(ValidationContext validationContext)
at System.ComponentModel.DataAnnotations.Validator.GetObjectValidationErrors(Object instance, ValidationContext validationContext, Boolean validateAllProperties, Boolean breakOnFi
rstError)
at System.ComponentModel.DataAnnotations.Validator.TryValidateObject(Object instance, ValidationContext validationContext, ICollection1 validationResults, Boolean validateAllProp erties) at NuGet.Manifest.TryValidate(Object value, ICollection1 results)
at NuGet.Manifest.Validate(Manifest manifest)
at NuGet.Manifest.ReadFrom(Stream stream, IPropertyProvider propertyProvider, Boolean validateSchema)
at NuGet.LocalPackage.ReadManifest(Stream manifestStream)
at NuGet.ZipPackage.EnsureManifest()
at NuGet.ZipPackage…ctor(String filePath, Boolean enableCaching)
at Squirrel.ReleasePackage.get_SuggestedReleaseFileName()
at Squirrel.Update.Program.Releasify(String package, String targetDir, String packagesDir, String bootstrapperExe, String backgroundGif, String signingOpts, String baseUrl, String
setupIcon, Boolean generateMsi, String frameworkVersion, Boolean generateDeltas)
at Squirrel.Update.Program.executeCommandLine(String[] args)
at Squirrel.Update.Program.main(String[] args)
System.MissingMethodException: Method not found: ‘Int32 System.Environment.get_CurrentManagedThreadId()’.
at NuGet.ManifestMetadata.d__108…ctor(Int32 <>1__state)
at NuGet.ManifestMetadata.Validate(ValidationContext validationContext)
at System.ComponentModel.DataAnnotations.Validator.GetObjectValidationErrors(Object instance, ValidationContext validationContext, Boolean validateAllProperties, Boolean breakOnFi
rstError)
at System.ComponentModel.DataAnnotations.Validator.TryValidateObject(Object instance, ValidationContext validationContext, ICollection1 validationResults, Boolean validateAllProp erties) at NuGet.Manifest.TryValidate(Object value, ICollection1 results)
at NuGet.Manifest.Validate(Manifest manifest)
at NuGet.Manifest.ReadFrom(Stream stream, IPropertyProvider propertyProvider, Boolean validateSchema)
at NuGet.LocalPackage.ReadManifest(Stream manifestStream)
at NuGet.ZipPackage.EnsureManifest()
at NuGet.ZipPackage…ctor(String filePath, Boolean enableCaching)
at Squirrel.ReleasePackage.get_SuggestedReleaseFileName()
at Squirrel.Update.Program.Releasify(String package, String targetDir, String packagesDir, String bootstrapperExe, String backgroundGif, String signingOpts, String baseUrl, String
setupIcon, Boolean generateMsi, String frameworkVersion, Boolean generateDeltas)
at Squirrel.Update.Program.executeCommandLine(String[] args)
at Squirrel.Update.Program.main(String[] args)
at Squirrel.Update.Program.Main(String[] args)


#2

did you add the squirrel event handler in your main.js(entry process).
if not try this,
on top use this,

if (handleSquirrelEvent(app)) {
    // squirrel event handled and app will exit in 1000ms, so don't do anything else
    return;
}

And add this in the end

function handleSquirrelEvent(application) {
    if (process.argv.length === 1) {
        return false;
    }
    const ChildProcess = require('child_process');
    const path = require('path');

    const appFolder = path.resolve(process.execPath, '..');
    const rootAtomFolder = path.resolve(appFolder, '..');
    const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
    const exeName = path.basename(process.execPath);

    const spawn = function(command, args) {
        let spawnedProcess, error;

        try {
            spawnedProcess = ChildProcess.spawn(command, args, {
                detached: true
            });
        } catch (error) {}

        return spawnedProcess;
    };

    const spawnUpdate = function(args) {
        return spawn(updateDotExe, args);
    };

    const squirrelEvent = process.argv[1];
    switch (squirrelEvent) {
        case '--squirrel-install':
        case '--squirrel-updated':
            // Optionally do things such as:
            // - Add your .exe to the PATH
            // - Write to the registry for things like file associations and
            //   explorer context menus

            // Install desktop and start menu shortcuts
            spawnUpdate(['--createShortcut', exeName]);

            setTimeout(application.quit, 1000);
            return true;

        case '--squirrel-uninstall':
            // Undo anything you did in the --squirrel-install and
            // --squirrel-updated handlers

            // Remove desktop and start menu shortcuts
            spawnUpdate(['--removeShortcut', exeName]);

            setTimeout(application.quit, 1000);
            return true;

        case '--squirrel-obsolete':
            // This is called on the outgoing version of your app before
            // we update to the new version - it's the opposite of
            // --squirrel-updated

            application.quit();
            return true;
    }
};


if the error is still there then try this installer build code along

// C:\Users\sdkca\Desktop\electron-workspace\build.js
var electronInstaller = require('electron-winstaller');

// In this case, we can use relative paths
resultPromise = electronInstaller.createWindowsInstaller({
    appDirectory: './your_app_directory',
    outputDirectory: './your_out_put_directory',
    authors: 'xxxxxxxxxx',
    owners:'xxxxxxxxxxxxxxxx',
    description:'xxxxxxxxxxxxxxxx',
    version:'0.0.0.'
  });
 
resultPromise.then(() => console.log( "It worked! "), (e) => console.log("No dice: ${e.message}"));

i hope this all works, it works for me…