diff --git a/packages/app-builder-lib/scheme.json b/packages/app-builder-lib/scheme.json index 2d2d6230610..48a1a0b7118 100644 --- a/packages/app-builder-lib/scheme.json +++ b/packages/app-builder-lib/scheme.json @@ -3839,6 +3839,13 @@ "description": "Whether to create start menu shortcut.", "type": "boolean" }, + "license": { + "description": "The path to EULA license file. Defaults to `license.txt` or `eula.txt` (or uppercase variants).\n\n**Note: MSI installers only support RTF format.** The license file must be in RTF format for WiX to display it properly.\n\nMultiple license files for different languages are supported — use lang postfix (e.g. `_de`, `_ru`). For example, create files `license_de.rtf` and `license_en.rtf` in the build resources.\nIf OS language is german, `license_de.rtf` will be displayed. See map of [language code to name](https://github.com/meikidd/iso-639-1/blob/master/src/data.js).\n\nAppropriate license file will be selected by language id. English is the default language.\n\nNote: This option is only applicable when `oneClick` is set to `false` (assisted installer). One-click installers do not show a license agreement page.", + "type": [ + "null", + "string" + ] + }, "menuCategory": { "default": false, "description": "Whether to create submenu for start menu shortcut and program files directory. If `true`, company name will be used. Or string value.", diff --git a/packages/app-builder-lib/src/options/MsiOptions.ts b/packages/app-builder-lib/src/options/MsiOptions.ts index 3b905847941..639d923f37a 100644 --- a/packages/app-builder-lib/src/options/MsiOptions.ts +++ b/packages/app-builder-lib/src/options/MsiOptions.ts @@ -28,4 +28,18 @@ export interface MsiOptions extends CommonWindowsInstallerConfiguration, TargetS * Any additional arguments to be passed to the light.ext, such as `["-cultures:ja-jp"]` */ readonly additionalLightArgs?: Array | null + + /** + * The path to EULA license file. Defaults to `license.txt` or `eula.txt` (or uppercase variants). + * + * **Note: MSI installers only support RTF format.** The license file must be in RTF format for WiX to display it properly. + * + * Multiple license files for different languages are supported — use lang postfix (e.g. `_de`, `_ru`). For example, create files `license_de.rtf` and `license_en.rtf` in the build resources. + * If OS language is german, `license_de.rtf` will be displayed. See map of [language code to name](https://github.com/meikidd/iso-639-1/blob/master/src/data.js). + * + * Appropriate license file will be selected by language id. English is the default language. + * + * Note: This option is only applicable when `oneClick` is set to `false` (assisted installer). One-click installers do not show a license agreement page. + */ + readonly license?: string | null } diff --git a/packages/app-builder-lib/src/targets/MsiTarget.ts b/packages/app-builder-lib/src/targets/MsiTarget.ts index cc323a020f2..92de4bbc1f7 100644 --- a/packages/app-builder-lib/src/targets/MsiTarget.ts +++ b/packages/app-builder-lib/src/targets/MsiTarget.ts @@ -11,6 +11,7 @@ import { Target } from "../core" import { DesktopShortcutCreationPolicy, FinalCommonWindowsInstallerOptions, getEffectiveOptions } from "../options/CommonWindowsInstallerConfiguration" import { normalizeExt } from "../platformPackager" import { getTemplatePath } from "../util/pathManager" +import { getNotLocalizedLicenseFile } from "../util/license" import { VmManager } from "../vm/vm" import { WineVmManager } from "../vm/WineVm" import { WinPackager } from "../winPackager" @@ -192,6 +193,15 @@ export default class MsiTarget extends Target { log.warn(`Manufacturer is not set for MSI — please set "author" in the package.json`) } + // Only include license file for assisted installer (oneClick === false) + let licenseRtfPath: string | null = null + if (commonOptions.isAssisted) { + const licenseFile = await getNotLocalizedLicenseFile(this.options.license, this.packager, ["rtf"]) + if (licenseFile != null) { + licenseRtfPath = this.vm.toVmFile(licenseFile) + } + } + return { ...commonOptions, iconPath: iconPath == null ? null : this.vm.toVmFile(iconPath), @@ -202,6 +212,7 @@ export default class MsiTarget extends Target { upgradeCode: this.upgradeCode, manufacturer: companyName || appInfo.productName, appDescription: appInfo.description, + licenseRtfPath, } } diff --git a/packages/app-builder-lib/templates/msi/template.xml b/packages/app-builder-lib/templates/msi/template.xml index 2d5cd3cc5c1..a5d034b7e98 100644 --- a/packages/app-builder-lib/templates/msi/template.xml +++ b/packages/app-builder-lib/templates/msi/template.xml @@ -58,6 +58,10 @@ {{ } -}} + {{ if (licenseRtfPath) { }} + + {{ } -}} + 1 OR CostingComplete = 1 diff --git a/test/src/windows/msiTest.ts b/test/src/windows/msiTest.ts index f7c9178ec11..1e3f6fdd105 100644 --- a/test/src/windows/msiTest.ts +++ b/test/src/windows/msiTest.ts @@ -129,4 +129,17 @@ describe.ifWindows("msi", { sequential: true }, () => { }, }, })) + + test.skip("assisted with license", ({ expect }) => + app(expect, { + targets: Platform.WINDOWS.createTarget("msi", Arch.x64), + config: { + appId: "build.electron.test.msi.assisted.license", + productName: "Test MSI Assisted License", + msi: { + oneClick: false, + license: "license_de.rtf", + }, + }, + })) })