Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow for NSIS windows installer to be wrapped in an MSI #7407

Merged
merged 8 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"eslint": "8.26.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.2.1",
"fast-xml-parser": "^4.0.15",
Copy link
Collaborator

@mmaietta mmaietta Feb 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be a dependency in app-builder-lib specifically. Not sure if prod or dev dependency though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-xml-parser is only referenced in the unit tests. So my thought is that it's only a devDependency here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh fair enough. Does it still need to be at the electron-builder workspace level or can it be installed within the /test/package.json then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and moved the dependency to the appropriate location, under test

"fs-extra": "10.1.0",
"globby": "11.1.0",
"husky": "7.0.4",
Expand Down
171 changes: 171 additions & 0 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -3699,6 +3699,167 @@
},
"type": "object"
},
"MsiWrappedOptions": {
"additionalProperties": false,
"properties": {
"additionalWixArgs": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"description": "Any additional arguments to be passed to the WiX installer compiler, such as `[\"-ext\", \"WixUtilExtension\"]`"
},
"artifactName": {
"description": "The [artifact file name template](/configuration/configuration#artifact-file-name-template).",
"type": [
"null",
"string"
]
},
"createDesktopShortcut": {
"default": true,
"description": "Whether to create desktop shortcut. Set to `always` if to recreate also on reinstall (even if removed by user).",
"enum": [
"always",
false,
true
]
},
"createStartMenuShortcut": {
"default": true,
"description": "Whether to create start menu shortcut.",
"type": "boolean"
},
"impersonate": {
"default": false,
"description": "Determines if the wrapped installer should be executed with impersonation",
"type": "boolean"
},
"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.",
"type": [
"string",
"boolean"
]
},
"oneClick": {
"type": "boolean"
},
"perMachine": {
"default": false,
"description": "Whether to install per all users (per-machine).",
"type": "boolean"
},
"publish": {
"anyOf": [
{
"$ref": "#/definitions/GithubOptions"
},
{
"$ref": "#/definitions/S3Options"
},
{
"$ref": "#/definitions/SpacesOptions"
},
{
"$ref": "#/definitions/GenericServerOptions"
},
{
"$ref": "#/definitions/CustomPublishOptions"
},
{
"$ref": "#/definitions/KeygenOptions"
},
{
"$ref": "#/definitions/SnapStoreOptions"
},
{
"$ref": "#/definitions/BitbucketOptions"
},
{
"items": {
"anyOf": [
{
"$ref": "#/definitions/GithubOptions"
},
{
"$ref": "#/definitions/S3Options"
},
{
"$ref": "#/definitions/SpacesOptions"
},
{
"$ref": "#/definitions/GenericServerOptions"
},
{
"$ref": "#/definitions/CustomPublishOptions"
},
{
"$ref": "#/definitions/KeygenOptions"
},
{
"$ref": "#/definitions/SnapStoreOptions"
},
{
"$ref": "#/definitions/BitbucketOptions"
},
{
"type": "string"
}
]
},
"type": "array"
},
{
"type": [
"null",
"string"
]
}
]
},
"runAfterFinish": {
"default": true,
"description": "Whether to run the installed application after finish. For assisted installer corresponding checkbox will be removed.",
"type": "boolean"
},
"shortcutName": {
"description": "The name that will be used for all shortcuts. Defaults to the application name.",
"type": [
"null",
"string"
]
},
"upgradeCode": {
"description": "The [upgrade code](https://msdn.microsoft.com/en-us/library/windows/desktop/aa372375(v=vs.85).aspx). Optional, by default generated using app id.",
"type": [
"null",
"string"
]
},
"warningsAsErrors": {
"default": true,
"description": "If `warningsAsErrors` is `true` (default): treat warnings as errors. If `warningsAsErrors` is `false`: allow warnings.",
"type": "boolean"
},
"wrappedInstallerArgs": {
"description": "Extra arguments to provide to the wrapped installer (ie: /S for silent install)",
"type": [
"null",
"string"
]
}
},
"type": "object"
},
"NotarizeOptions": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -6791,6 +6952,16 @@
],
"description": "MSI project created on disk - not packed into .msi package yet."
},
"msiWrapped": {
"anyOf": [
{
"$ref": "#/definitions/MsiWrappedOptions"
},
{
"type": "null"
}
]
},
"nodeGypRebuild": {
"default": false,
"description": "Whether to execute `node-gyp rebuild` before starting to package the app.\n\nDon't [use](https://github.com/electron-userland/electron-builder/issues/683#issuecomment-241214075) [npm](http://electron.atom.io/docs/tutorial/using-native-node-modules/#using-npm) (neither `.npmrc`) for configuring electron headers. Use `electron-builder node-gyp-rebuild` instead.",
Expand Down
3 changes: 3 additions & 0 deletions packages/app-builder-lib/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { AppXOptions } from "./options/AppXOptions"
import { AppImageOptions, DebOptions, FlatpakOptions, LinuxConfiguration, LinuxTargetSpecificOptions } from "./options/linuxOptions"
import { DmgOptions, MacConfiguration, MasConfiguration } from "./options/macOptions"
import { MsiOptions } from "./options/MsiOptions"
import { MsiWrappedOptions } from "./options/MsiWrappedOptions"
import { PkgOptions } from "./options/pkgOptions"
import { PlatformSpecificBuildOptions } from "./options/PlatformSpecificBuildOptions"
import { SnapOptions } from "./options/SnapOptions"
Expand Down Expand Up @@ -73,6 +74,8 @@ export interface Configuration extends PlatformSpecificBuildOptions {
readonly appx?: AppXOptions | null
/** @private */
readonly msi?: MsiOptions | null
/** @private */
readonly msiWrapped?: MsiWrappedOptions | null
readonly squirrelWindows?: SquirrelWindowsOptions | null

/**
Expand Down
1 change: 1 addition & 0 deletions packages/app-builder-lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export { PkgOptions, PkgBackgroundOptions, BackgroundAlignment, BackgroundScalin
export { WindowsConfiguration } from "./options/winOptions"
export { AppXOptions } from "./options/AppXOptions"
export { MsiOptions } from "./options/MsiOptions"
export { MsiWrappedOptions } from "./options/MsiWrappedOptions"
export { CommonWindowsInstallerConfiguration } from "./options/CommonWindowsInstallerConfiguration"
export { NsisOptions, NsisWebOptions, PortableOptions, CommonNsisOptions } from "./targets/nsis/nsisOptions"
export { LinuxConfiguration, DebOptions, CommonLinuxOptions, LinuxTargetSpecificOptions, AppImageOptions, FlatpakOptions } from "./options/linuxOptions"
Expand Down
31 changes: 31 additions & 0 deletions packages/app-builder-lib/src/options/MsiWrappedOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { TargetSpecificOptions } from "../core"
import { CommonWindowsInstallerConfiguration } from "./CommonWindowsInstallerConfiguration"

export interface MsiWrappedOptions extends CommonWindowsInstallerConfiguration, TargetSpecificOptions {
/**
* Extra arguments to provide to the wrapped installer (ie: /S for silent install)
*/
readonly wrappedInstallerArgs?: string | null

/**
* Determines if the wrapped installer should be executed with impersonation
* @default false
*/
readonly impersonate?: boolean

/**
* The [upgrade code](https://msdn.microsoft.com/en-us/library/windows/desktop/aa372375(v=vs.85).aspx). Optional, by default generated using app id.
*/
readonly upgradeCode?: string | null

/**
* If `warningsAsErrors` is `true` (default): treat warnings as errors. If `warningsAsErrors` is `false`: allow warnings.
* @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
}
11 changes: 10 additions & 1 deletion packages/app-builder-lib/src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ export class Packager {

private async doBuild(): Promise<Map<Platform, Map<string, Target>>> {
const taskManager = new AsyncTaskManager(this.cancellationToken)
const syncTargetsIfAny = [] as Target[]

const platformToTarget = new Map<Platform, Map<string, Target>>()
const createdOutDirs = new Set<string>()
Expand Down Expand Up @@ -446,11 +447,19 @@ export class Packager {
}

for (const target of nameToTarget.values()) {
taskManager.addTask(target.finishBuild())
if (target.isAsyncSupported) {
taskManager.addTask(target.finishBuild())
} else {
syncTargetsIfAny.push(target)
}
}
}

await taskManager.awaitTasks()

for (const target of syncTargetsIfAny) {
await target.finishBuild()
}
return platformToTarget
}

Expand Down