Skip to content

Commit

Permalink
feat: Allow specifying additional WiX compiler options (#5813)
Browse files Browse the repository at this point in the history
* Allow specifying additional WiX compiler options
  • Loading branch information
p120ph37 committed May 3, 2021
1 parent 6237e67 commit 4e2909c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -3388,6 +3388,13 @@
"default": true,
"description": "If `warningsAsErrors` is `true` (default): treat warnings as errors. If `warningsAsErrors` is `false`: allow warnings.",
"type": "boolean"
},
"additionalWixArgs": {
"description": "Any additional arguments to be passed to the WiX installer compiler, such as `[\"-ext\", \"WixUtilExtension\"]`",
"type": [
"null",
"array"
]
}
},
"type": "object"
Expand Down
5 changes: 5 additions & 0 deletions packages/app-builder-lib/src/options/MsiOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ export interface MsiOptions extends CommonWindowsInstallerConfiguration, TargetS
* @default true
*/
readonly warningsAsErrors?: boolean

/**
* Any additional arguments to be passed to the WiX installer compiler, such as `["-ext", "WixUtilExtension"]`
*/
readonly additionalWixArgs?: Array<string> | null
}
3 changes: 3 additions & 0 deletions packages/app-builder-lib/src/targets/MsiTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ export default class MsiTarget extends Target {
if (this.options.warningsAsErrors !== false) {
args.push("-wx")
}
if (this.options.additionalWixArgs != null) {
args.push(...this.options.additionalWixArgs)
}
return args
}

Expand Down
40 changes: 40 additions & 0 deletions test/src/windows/msiTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { app } from "../helpers/packTester"
import { Platform } from "electron-builder"
import fs from "fs"

test.ifAll.ifDevOrWinCi(
"msi",
Expand Down Expand Up @@ -62,6 +63,45 @@ test.ifAll.ifDevOrWinCi(
)
)

const wixArgsProductName = "Test WiX Args";
test.ifAll.ifDevOrWinCi(
"wix args",
app(
{
targets: Platform.WINDOWS.createTarget("msi"),
config: {
appId: "build.electron.test.msi.oneClick.wixArgs",
extraMetadata: {
// version: "1.0.0",
},
productName: wixArgsProductName,
// Inject a custom-action which requires the WixUtilExtension DLL
msiProjectCreated: async (path) => {
await fs.promises.writeFile(path, (await fs.promises.readFile(path, "utf8")).replace(
'</Product>',
`<util:CloseApplication xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"
PromptToContinue="no"
Target="${wixArgsProductName}.exe"
CloseMessage="yes"
Timeout="2"
TerminateProcess="1"
RebootPrompt="no"
/>
</Product>`
));
},
msi: {
// Apply the needed DLL
additionalWixArgs: ["-ext", "WixUtilExtension"],
},
},
},
{
// signed: true,
}
)
)

test.skip.ifAll(
"assisted",
app({
Expand Down

0 comments on commit 4e2909c

Please sign in to comment.