Skip to content

[v2] NSIS installer support for Windows#1184

Merged
leaanthony merged 3 commits into
wailsapp:masterfrom
stffabi:feature/nsis-installer
Mar 2, 2022
Merged

[v2] NSIS installer support for Windows#1184
leaanthony merged 3 commits into
wailsapp:masterfrom
stffabi:feature/nsis-installer

Conversation

@stffabi

@stffabi stffabi commented Feb 25, 2022

Copy link
Copy Markdown
Contributor
  • Brings support for NSIS installer building for Windows
  • Adds support for build-level build-hooks
  • Populate manifest and app info files from wails.json by leveraging go templating.

Closes #1124
Closes #1135
Closes #1155

@leaanthony

Copy link
Copy Markdown
Member

@jponc

@leaanthony leaanthony left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this - it's awesome stuff! Just a couple of comments to discuss and I think we're good to go.

Comment thread v2/pkg/commands/build/build.go

SetRegView 64
# If this key exists and is not empty then webview2 is already installed
ReadRegStr $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are 2 keys to check for installation depending on whether it was installed by an admin or not:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}

HKEY_CURRENT_USER\Software\Microsoft\EdgeUpdate\Clients{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As the installer per default is run elevated it makes sense to only check against the admin key. If we wouldn't do that, an installer which is run elevated and installs the app for all users, the app would only work for that specific user and not for all user. Or does an installation by a non admin user work for other users on the same machine?

This check is also just a fastpath, if it doesn't work the bootstrapper will detect the runtime is installed and won't do anything. So it would be just a waste of time and probably bandwidth during the installation.

I think the best would be to do the following:

  • If the installer is run elevated just check against the admin key.
  • If the installer is not run elevated, first check against the admin key and then the current user key.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The reason I bring it up is that running it elevated was a temporary work around as MS did a breaking change (they created a user install key but didn't publish it). Installing the runtime with user privileges is the best scenario as it'll work in all environments (eg corporate). I reverted the "admin install" change today as we don't need it any more (we detect installation by asking webview2loader.dll what version is installed. I agree with your summary at the end.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I agree with that for the embedded install case. For the installer it's slightly different, and for corporate environments the installation must almost always be performed by an admin.

So I'll go ahead and change the NSIS tools accordingly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't find a reliable way to determine the execution level of the installer that satisfied me. Therefore I've introduced a new define !define REQUEST_EXECUTION_LEVEL "admin" that user can use to change the execution level. This define is then taken into account in the wails_tools.nsh to also check the user specific key if needed.

Comment thread v2/pkg/buildassets/buildassets.go Outdated
Info: projectData.Info,
}

data.Internal.Webview2RuntimeSetupPath = filepath.Join(fs.RelativePath("../../"), "internal", "webview2runtime", "MicrosoftEdgeWebview2Setup.exe")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We're moving away from assuming the Wails CLI is installed as a Go module so we don't want to reference files relative to the source. I think we should copy this setup file into a temp directory. I've added a method to the webview2runtime package to do this. Perhaps we could use os.TempDir()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, didn't have that in mind. Thanks for the WriteInstaller method.

I would like to keep the property that the installer could be created outside of wails for debugging and test purposes after a first wails build --nsis. So I'll probably just write it into build/windows/installer/tools/ instead of having it in a TempDir and leave the file leaking space there.
What do you think?

@leaanthony leaanthony Feb 26, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, I thought that initially but then it'd be easy to check in with your project. The reason I suggested temp dir was because I assumed it would be deleted anyway. If you really want it in the build dir, lets add a .gitignore to the default tempalates.

@stffabi stffabi Feb 26, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well we have to define if we wanna keep the property of being able to run makensis outside of wails for debugging purposes or not. If we want to get rid of that property I'm fine doing it completely in a temp dir and deleting it afterwards.
I also agree with you to add a .gitignore, I also wanted to do that for the "wails_tools.nsh" which also get's auto generated and written back into build/windows/installer/ to support this property.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What do you think about the property of being able to run makensis outside of wails for debugging purposes?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Given everything you've said, I'd suggest dumping it in the build dir and add a .gitignore is fine 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great, I'll update the PR on monday

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

.gitignore entries have been added.

stffabi added 2 commits March 1, 2022 09:15
Currently only supports build-level hooks
… generation

The manifest asset files are now a go template and data will be
resolved before they are included into the build output.

Breaking Change: Windows manifest file must be named
“wails.exe.manifest” and doesn’t depend on the project name
anymore.
@stffabi stffabi force-pushed the feature/nsis-installer branch from 8bfba89 to c7b965a Compare March 1, 2022 08:18
@stffabi stffabi force-pushed the feature/nsis-installer branch from c7b965a to a236563 Compare March 1, 2022 08:55
@leaanthony

Copy link
Copy Markdown
Member

Thanks for all the hard work on this 🙏

@leaanthony leaanthony merged commit b02dbfa into wailsapp:master Mar 2, 2022
ianmjones pushed a commit to ianmjones/wails that referenced this pull request Mar 2, 2022
* [v2] Add support for post build hooks

Currently only supports build-level hooks

* [v2] Improve build assets handling and use single source for manifest generation

The manifest asset files are now a go template and data will be
resolved before they are included into the build output.

Breaking Change: Windows manifest file must be named
“wails.exe.manifest” and doesn’t depend on the project name
anymore.

* [v2, windows] NSIS installer generation
@stffabi stffabi deleted the feature/nsis-installer branch March 2, 2022 19:17
@stffabi

stffabi commented Mar 2, 2022

Copy link
Copy Markdown
Contributor Author

Awesome, thanks so much for merging.

leaanthony pushed a commit that referenced this pull request Mar 8, 2022
* [v2] Add support for post build hooks

Currently only supports build-level hooks

* [v2] Improve build assets handling and use single source for manifest generation

The manifest asset files are now a go template and data will be
resolved before they are included into the build output.

Breaking Change: Windows manifest file must be named
“wails.exe.manifest” and doesn’t depend on the project name
anymore.

* [v2, windows] NSIS installer generation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single source of truth for manifest data NSIS Support for Windows Preinstall wails

2 participants