Electron-builder: Build Error on Windows when add fileAssociations config.

Created on 18 Dec 2018  Â·  2Comments  Â·  Source: electron-userland/electron-builder

  • Target: Windows


Build Error on Windows when add fileAssociations config. Work well in MacOS and No fileAssociations in Windows

  • electron-builder version=20.38.2
  • loaded configuration file=package.json ("build" field)
  • rebuilding native production dependencies platform=win32 arch=x64
  • packaging       platform=win32 arch=x64 electron=3.0.13 appOutDir=dist\win-unpacked
  • rebuilding native production dependencies platform=win32 arch=ia32
  • packaging       platform=win32 arch=ia32 electron=3.0.13 appOutDir=dist\win-ia32-unpacked
  • building        target=nsis file=dist\App Setup 0.9.3.exe archs=x64, ia32 oneClick=false perMachine=true
Error: ~\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.3.2\Bin\makensis.exe exited with code 1
Output:
Command line defined: "APP_ID=com.zhongyu.app"
Command line defined: "APP_GUID=091db515-e9cb-5445-af4f-6228b9077b5b"
Command line defined: "UNINSTALL_APP_KEY=091db515-e9cb-5445-af4f-6228b9077b5b"
Command line defined: "PRODUCT_NAME=App"
Command line defined: "PRODUCT_FILENAME=App"
Command line defined: "APP_FILENAME=app"
Command line defined: "APP_DESCRIPTION=App"
Command line defined: "VERSION=0.9.3"
Command line defined: "PROJECT_DIR=~\app\app"
Command line defined: "BUILD_RESOURCES_DIR=~\app\app\build"
Command line defined: "MUI_ICON=~\app\app\dist\.icon-ico\icon.ico"
Command line defined: "MUI_UNICON=~\app\app\dist\.icon-ico\icon.ico"
Command line defined: "APP_32=~\app\app\dist\app-0.9.3-ia32.nsis.7z"
Command line defined: "APP_32_NAME=app-0.9.3-ia32.nsis.7z"
Command line defined: "APP_32_HASH=A46677B05BB9BE36F5BCD8B1E996DA0A81089E4941E9266761230747AA943A5C58DDC8011A8C4580F856B965C60AFCA076B11531D649FC36865517204E506C1C"
Command line defined: "APP_64=~\app\app\dist\app-0.9.3-x64.nsis.7z"
Command line defined: "APP_64_NAME=app-0.9.3-x64.nsis.7z"
Command line defined: "APP_64_HASH=7F1EA15CB9B502793ED4193BF61FB30B6E57BA90773720D1CF478B2C96D690CF6A5D3A247EF5898C44AA4D1A934202D89F479E50D633A27C481E2ADECE2DE676"
Command line defined: "COMPANY_NAME=Zeno Chiu"
Command line defined: "APP_PRODUCT_FILENAME=App"
Command line defined: "APP_INSTALLER_STORE_FILE=app-updater\installer.exe"
Command line defined: "COMPRESSION_METHOD=7z"
Command line defined: "MULTIUSER_INSTALLMODE_ALLOW_ELEVATION"
Command line defined: "INSTALL_MODE_PER_ALL_USERS"
Command line defined: "INSTALL_MODE_PER_ALL_USERS_REQUIRED"
Command line defined: "allowToChangeInstallationDirectory"
Command line defined: "SHORTCUT_NAME=App"
Command line defined: "UNINSTALL_DISPLAY_NAME=App 0.9.3"
Command line defined: "MUI_WELCOMEFINISHPAGE_BITMAP=${NSISDIR}\Contrib\Graphics\Wizard\nsis3-metro.bmp"
Command line defined: "MUI_UNWELCOMEFINISHPAGE_BITMAP=${NSISDIR}\Contrib\Graphics\Wizard\nsis3-metro.bmp"
Command line defined: "ESTIMATED_SIZE=303143"
Command line defined: "COMPRESS=auto"
Command line defined: "UNINSTALLER_OUT_FILE=~\app\app\dist\.__uninstaller-nsis-app.exe"
Processing config: ~\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.3.2\nsisconf.nsh
Processing script file: "<stdin>" (ACP)

Error output:
Bad text encoding
Error in script "<stdin>" on line 79 -- aborting creation process

    at ChildProcess.childProcess.once.code (~\app\node_modules\builder-util\src\util.ts:244:14)
    at Object.onceWrapper (events.js:273:13)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:962:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)

Most helpful comment

I have the same problem, and after a period of debugging, I found a solution.

makensis.exe have an option /INPUTCHARSET UTF8 to set input charset to utf-8.

So I modify the file NsisTarget.js in node_module electron-builder-lib.
Find the function executeMakensis, add code args.push("-INPUTCHARSET", "UTF8"); after definition of const args. After modify, the code looks like:

    executeMakensis(defines, commands, script) {
        var _this6 = this;

        return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
            const args = _this6.options.warningsAsErrors === false ? [] : ["-WX"];
            args.push("-INPUTCHARSET", "UTF8"); //this line was added
            for (const name of Object.keys(defines)) {
                const value = defines[name];
                if (value == null) {
                    args.push(`-D${name}`);
                } else {
                    args.push(`-D${name}=${value}`);
                }
            }
            ...
        })();
    }

All 2 comments

I have the same problem, and after a period of debugging, I found a solution.

makensis.exe have an option /INPUTCHARSET UTF8 to set input charset to utf-8.

So I modify the file NsisTarget.js in node_module electron-builder-lib.
Find the function executeMakensis, add code args.push("-INPUTCHARSET", "UTF8"); after definition of const args. After modify, the code looks like:

    executeMakensis(defines, commands, script) {
        var _this6 = this;

        return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
            const args = _this6.options.warningsAsErrors === false ? [] : ["-WX"];
            args.push("-INPUTCHARSET", "UTF8"); //this line was added
            for (const name of Object.keys(defines)) {
                const value = defines[name];
                if (value == null) {
                    args.push(`-D${name}`);
                } else {
                    args.push(`-D${name}=${value}`);
                }
            }
            ...
        })();
    }

path: node_module/app-builder-lib/out/targets/nsis/NsisTarget.js

Was this page helpful?
0 / 5 - 0 ratings