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

Add support for upgrading the CommandNotFound module #32766

Merged
merged 15 commits into from May 16, 2024

Conversation

carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented May 7, 2024

Summary of the Pull Request

  • CommandNotFound PowerShell module changes
    • Removes the CommandNotFound source code since that'll soon be moved to another repository
  • Microsoft.WinGet.Client PowerShell module changes
    • Enforces a version requirement for the Microsoft.WinGet.Client. Upgrading to 1.8.1133 allows support for ARM64.
  • ARM64 support
    • Removes any logic checking for ARM64, since that works now when upgrading the Microsoft.WinGet.Client module.
    • Settings UI was updated to remove these checks since they're no longer necessary.
  • PowerShell profile changes
    • GUID f45873b3-b655-43a6-b217-97c00aa0db58 is now used in the PowerShell profile comment to denote that the module was installed/enabled
    • GUID 34de4b3d-13a8-4540-b76d-b9e8d3851756 (the old one) is used to detect that an upgrade is available (and we upgrade to the one above appropriately)

Related Issues

#30818

PR Checklist

Validation Steps Performed

  • Validated each ps1 script by running it locally
  • PSGallery has been updated with Microsoft.WinGet.CommandNotFound module

Based on some work by @snickler

@carlos-zamora
Copy link
Member Author

Looking through #30818, looks like we still need the ARM64 check due to...

There's no PowerShell 7.4 MSI installer for arm64, so arm64 isn't currently supported.

Also need to look into...

It doesn't work with PowerShell installed from MSIX or from the Microsoft Store, since we depend on powershellgallery.com/packages/Microsoft.WinGet.Client/1.6.3133.0 which doesn't work for those cases.

... to see if the updated Microsoft.WinGet.Client module works in those cases.

@snickler
Copy link
Collaborator

snickler commented May 8, 2024

Looking through #30818, looks like we still need the ARM64 check due to...

There's no PowerShell 7.4 MSI installer for arm64, so arm64 isn't currently supported.

Also need to look into...

It doesn't work with PowerShell installed from MSIX or from the Microsoft Store, since we depend on powershellgallery.com/packages/Microsoft.WinGet.Client/1.6.3133.0 which doesn't work for those cases.

... to see if the updated Microsoft.WinGet.Client module works in those cases.

For the 7.4 installer for arm64, I wonder if we can just have it open "ms-windows-store://pdp/?ProductId=9mz1snwt0n5d" which would bring it right to the store installer.

The PowerShell module will work in MSIX Store Installer due to the changes made in the 1.8 release that fixed the COM crashing.

@carlos-zamora
Copy link
Member Author

@jaimecbernardo Added in the UpgradeModule.ps1 script and made it a part of Product.wxs. Pulling you in to figure out the installer bits 😊

@jaimecbernardo
Copy link
Collaborator

I've added a couple of commits to have this run CI and be able to build well:

  • Fix XAML style.
  • Remove the CmdNotFound project from .sln too.

@jaimecbernardo
Copy link
Collaborator

Thanks for the contribution and the changes 😄
I think everything for the installer is in place. I'll build an installer and test the scenarios to see if it's good.

Add-Content -Path $PROFILE -Value "`r`nImport-Module `"$scriptPath\WinGetCommandNotFound.psd1`""
Add-Content -Path $PROFILE -Value "#34de4b3d-13a8-4540-b76d-b9e8d3851756"
Add-Content -Path $PROFILE -Value "`r`n#f45873b3-b655-43a6-b217-97c00aa0db58 PowerToys CommandNotFound module"
Add-Content -Path $PROFILE -Value "`r`nImport-Module -Name Microsoft.WinGet.CommandNotFound`""
Copy link
Collaborator

Choose a reason for hiding this comment

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

@carlos-zamora , have you tested this? (when the module is not installed and you install from scratch?)
image

@jaimecbernardo
Copy link
Collaborator

The upgradeModule.ps1 seems to be running from the installer but not doing anything at first look.
@carlos-zamora , tried to run the script directly and got this
image
Shouldn't the Upgrade-Module references be Update-Module instead?

@snickler
Copy link
Collaborator

snickler commented May 9, 2024 via email

@jaimecbernardo
Copy link
Collaborator

Current status: Figuring out why the script seems to do nothing when running from the installer.

@snickler
Copy link
Collaborator

snickler commented May 9, 2024

Current status: Figuring out why the script seems to do nothing when running from the installer.

Hmmmm a good thing to try is commenting out the starting portions of the script that run Test-Path against $PROFILE. If it continues on and does something, then it could mean there's potentially an issue with the instance failing to set the variable that points to the PowerShell profile script?

@jaimecbernardo
Copy link
Collaborator

Figured it out, we were not passing the install folder as an argument to the custom action 😅 .
Regarding the new "Microsoft.WinGet.CommandNotFound", it's getting shipped with WinGet, is that what's happening @carlos-zamora ?

@carlos-zamora
Copy link
Member Author

Regarding the new "Microsoft.WinGet.CommandNotFound", it's getting shipped with WinGet, is that what's happening @carlos-zamora ?

No, actually. The module source code is moving into its own repo. From there, it'll be built/signed, then published to PSGallery.

@jaimecbernardo
Copy link
Collaborator

Regarding the new "Microsoft.WinGet.CommandNotFound", it's getting shipped with WinGet, is that what's happening @carlos-zamora ?

No, actually. The module source code is moving into its own repo. From there, it'll be built/signed, then published to PSGallery.

So, how will the module get to be installed from PSGallery? I think that's still missing from this PR, if I'm interpreting it correctly.

@carlos-zamora
Copy link
Member Author

Regarding the new "Microsoft.WinGet.CommandNotFound", it's getting shipped with WinGet, is that what's happening @carlos-zamora ?

No, actually. The module source code is moving into its own repo. From there, it'll be built/signed, then published to PSGallery.

So, how will the module get to be installed from PSGallery? I think that's still missing from this PR, if I'm interpreting it correctly.

Oops! Good catch! Updated!

This comment has been minimized.

@jaimecbernardo
Copy link
Collaborator

We're going for building the release candidate later today. Were these changes intended for this release?

@carlos-zamora
Copy link
Member Author

We're going for building the release candidate later today. Were these changes intended for this release?

Yes! Final changes were made to the CommandNotFound module in the other repo and the pipeline successfully ran and output the signed module. I'm uploading it to the PSGallery today. Reviews would be appreciated to get this into the release 😊. Sorry it's coming in so close to the deadline!

@carlos-zamora carlos-zamora marked this pull request as ready for review May 16, 2024 07:12
Copy link
Collaborator

@stefansjfw stefansjfw left a comment

Choose a reason for hiding this comment

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

Change looks good to me.

I tested upgrade scenario, clean install and uninstall on win11 on x64. Also, tested on Win10 Arm64 device. Everything works as expected

@jaimecbernardo jaimecbernardo merged commit e1832a0 into main May 16, 2024
16 checks passed
@carlos-zamora carlos-zamora deleted the dev/cazamor/cmdNotFound-upgrade branch May 16, 2024 21:00
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.

None yet

4 participants