electron-userland/electron-builder

nsis - portable & installer

kossolax opened this issue · 12 comments

  • Version: 14.5.3
  • Target: win64 - nsis/portable

When you are building both portable and installer, building fails. I'm using electron-builder@14.5.3

Exception: The process cannot access the file because it is being used by another process.
package.json:

    "win": {
      "target": ["nsis", "portable"],
    },
    "nsis": {
      "unicode": false,
      "artifactName": "${productName}Installer.${version}.${ext}",
    }

I suppose both output have the same artifactName and the same temporary file name (.nsis.7z), Can we also have a new file macro depending on installer-portable version we are building?
${productName}${buildTarget}.${version}.${ext}

Thanks

Specify custom artifactName in the portable.

"portable": {
      "unicode": false,
      "artifactName": "${productName}Installer.${version}.${ext}",
    }

But.... damn. You cannot due to config verification :(

same here:

    "electron": "^1.6.1",
    "electron-builder": "^15.1.1",
"win": {
      "target": [
        "nsis",
        "portable",
        "7z",
        "zip"
      ]
    }

#1340 (comment) working again in the 15.3.0+

I think you fixed the artifact name, but I still can't build.

Here is package.json:

    "win": {
      "target": ["nsis", "portable"]
    },
    "nsis": {
      "unicode": false,
      "artifactName": "${productName}Installer.${version}.${ext}"
    },
    "portable": {
      "unicode": false,
      "artifactName": "${productName}Portable.${version}.${ext}"
    }

and error output:

build -w --x64 --publish never

Packaging for win32 x64 using electron 1.4.15 to dist\win-unpacked
Building NSIS installer
Building NSIS installer
Packaging NSIS installer for arch x64
Packaging NSIS installer for arch x64
Error: C:[...]\node_modules\7zip-bin-win\x64\7za.exe exited with code 2
Output:
[...]
Error:
cannot open file
C:[...]\dist\designer-0.5.1-x64.nsis.7z
The file exists.

So both portable and nsis run in parallel, both trying to create temporary file, at the same time xxx-yyy-x64.nsis.7z.

Thanks for your care

I forgot to mention that's I've tested using electron-builder 15.4.1 version.

@kossolax Fixed in 15.4.2. Test added.

I've updated to 15.4.2, but building still fail. I suppose your previous patch fix when you don't set a artifactName at all. Sorry to insist, but it's look like we don't understand each others.

If I build only a portable version it works. If I build only a nsis installer version it works. If I build both at the same time by setting "target": ["nsis", "portable"]" it still doesn't work.

The process cannot access the file because it is being used by another process.

I'm pretty sure it's because both process run in parallel, and both trying to build the archive with the same temporary name "designer-0.5.1-x64.nsis.7z". Please note the "temporary name" is not the same as the final artifact name. "DesignerInstaller.0.5.1.exe"

I hope this clarify issue.

Hello,

You could change this line into something like...

const archiveFile = path.join(this.outDir, ${packager.appInfo.name}-${packager.appInfo.version}-${this.isPortable ? "portable" : "setup"}-${packager.appInfo.version}-${packager.appInfo.version}-${Arch[arch]}.nsis.${format})

So both will create differents temp ".nsis.7z" file. Sadly, this throw another error while converting the .nsis.7z file into a .exe files. The target .exe file is only 150 Ko, and .nsis.7z disapeard.

electron-builder@16.5.1

Error: C:[...]\nsis\nsis-3.0.1.10\Bin\makensis.exe exited with code 1
[...]
Command line defined: "APP_64=C:[...]\Designer\dist\designer-portable-0.7.0-x64.nsis.7z"
Command line defined: "APP_64_NAME=designer-portable-0.7.0-x64.nsis.7z"
[...]
Output: "C:[...]\Designer\dist\DesignerPortable.0.7.0.exe"

Error output:
Can't open output file
Error - aborting creation process

Hello again,

Thanks for your update.

When I'm building, I've only one artifact build, but the error is gone. Here is my package.json
It's look like both portable & nsis are building into same artifactName.

    "win": {
      "target": ["nsis", "portable"],
      "icon": "resources/images/logo.ico"
    },
    "nsis": {
      "artifactName": "${productName}Installer.${version}.${ext}",
      "installerIcon": "resources/images/logo.ico",
      "installerHeaderIcon": "resources/images/logo.ico"
    },
    "portable": {
      "artifactName": "${productName}Portable.${version}.${ext}"
    }

I was watching file creation process:

  • building 7z file
  • creating portable.exe 0Ko
  • building portable.exe 150 Ko
  • merging 7z into portable.exe 30Mo
  • creating portable.exe 0Ko
  • building portable.exe 150 Ko
  • merging 7z into portable.exe 30Mo

You can notice the output file at line 238 and 274 from log. err.txt

Hello,

I've just tested with the 17.0.2 version, same issue. @hovancik have you got the same issue ?

For the record, I also have the same behavior. I have to build nsis and portable separately in order to have both.

Hello again,
The issue is still present on lastest release, but the issue is only present when you specify a custom artifact name.

Otherwise the compilation produce correctly the 2 outputs.

https://github.com/electron-userland/electron-builder/blob/master/packages/electron-builder/src/targets/nsis.ts#L132

But it doesn't with that's kind of config:

    "nsis": {
      "artifactName": "${productName}Installer.${version}.${ext}",
      "installerIcon": "resources/images/logo.ico",
      "installerHeaderIcon": "resources/images/logo.ico",
    },
    "portable": {
      "artifactName": "${productName}Portable.${version}.${ext}"
    }

I hope this help.