Skip to content

🩹 [Patch]: Fix Windows PowerShell downgrade installation #4

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

Merged
merged 10 commits into from
Jun 14, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 14, 2025

This pull request refines the PowerShell installation process on Windows based GitHub runners.

Windows-Specific Enhancements:

  • Added detection for currently installed PowerShell versions and introduced logic to handle downgrades, including uninstalling existing versions if necessary.
  • Improved uninstall command handling for MSI-based PowerShell installations by ensuring quiet and no-restart flags are added.

Copilot AI and others added 2 commits June 14, 2025 08:22
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
…tionality

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] 🩹 [Patch]: Ensure downgrade when requested on Windows 🩹 [Patch]: Fix Windows PowerShell downgrade installation Jun 14, 2025
@Copilot Copilot AI requested a review from MariusStorhaug June 14, 2025 08:25
Copilot finished work on behalf of MariusStorhaug June 14, 2025 08:25
@MariusStorhaug
Copy link
Member

Is it as simple as removing what you have added so far, but instead modifying the installation command to use force for windows based installations? Seems that we can use that even if it is an upgrade. With this approach we also can remove the eval to the degrade that you also added.

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jun 14, 2025

Is it as simple as removing what you have added so far, but instead modifying the installation command to use force for windows based installations? Seems that we can use that even if it is an upgrade...

You're absolutely right! I've simplified the approach by removing all the version comparison logic and using msiexec /f for all Windows installations. This is much cleaner and more reliable. The force flag works for upgrades, downgrades, and fresh installs uniformly. Thanks for the suggestion! (f646cd3)

Copilot finished work on behalf of MariusStorhaug June 14, 2025 14:47
@MariusStorhaug
Copy link
Member

Change of plan. Lets use the current logic to find if we are doing a downgrade using the version class and parse the versions. We need to reinstall the package if it is a downgrade request.

…etection

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jun 14, 2025

Change of plan. Lets use the current logic to find if we are doing a downgrade using the version class and parse the versions. We need to reinstall the package if it is a downgrade request.

I've implemented the version comparison logic as requested. The Windows installation now uses PowerShell's [version] class to detect downgrade scenarios and applies the appropriate msiexec flags:

  • /f (force reinstall) for downgrades to overwrite existing installations
  • /i (regular install) for upgrades and fresh installations

The logic includes error handling for version parsing edge cases and preserves the existing behavior for same versions. (00a357a)

Copilot finished work on behalf of MariusStorhaug June 14, 2025 15:08
@MariusStorhaug
Copy link
Member

The test that would downgrade to 7.4.7 is still failing. Seems the install just shortcircuts. How about we add a REINSTALL variable with the value 'a'?

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jun 14, 2025

The test that would downgrade to 7.4.7 is still failing. Seems the install just shortcircuts. How about we add a REINSTALL variable with the value 'a'?

Added REINSTALL=a parameter to the msiexec command for downgrade scenarios. This ensures a complete reinstall of all features, which should resolve the shortcircuiting issue. The downgrade test case has been re-added to validate the fix. (3fe7f7d)

Copilot finished work on behalf of MariusStorhaug June 14, 2025 15:20
@MariusStorhaug
Copy link
Member

Lets add a section for the windows based downgrade to uninstall the previous version before installing the new version.

…grades

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jun 14, 2025

Lets add a section for the windows based downgrade to uninstall the previous version before installing the new version.

Implemented the uninstall-then-install approach for Windows PowerShell downgrades. The logic now finds the existing PowerShell installation via registry lookup, extracts the product code, uses msiexec /x to uninstall the current version, then installs the requested version with msiexec /i. This provides a cleaner approach than the previous force reinstall method. (55afe33)

Copilot finished work on behalf of MariusStorhaug June 14, 2025 16:20
…nstallation if the requested version is already installed
@MariusStorhaug MariusStorhaug marked this pull request as ready for review June 14, 2025 22:07
@Copilot Copilot AI review requested due to automatic review settings June 14, 2025 22:07
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refines the PowerShell installation process for Windows GitHub runners by improving downgrade detection and uninstall handling.

  • Improved download and installation messages for Linux and macOS.
  • Introduced Windows-specific downgrade detection and uninstallation logic.
  • Fixed minor typos in echo messages.
Comments suppressed due to low confidence (2)

action.yml:233

  • Using 'StartsWith' to match the display version may be too broad and could select unintended versions. Consider casting the DisplayVersion to a proper version object and comparing it explicitly to ensure accurate version matching.
              $_.DisplayVersion -and $_.DisplayVersion.StartsWith($detected)

action.yml:236

  • [nitpick] Selecting the first matching uninstall entry may be ambiguous if multiple entries exist. It would be helpful to add a comment clarifying the criteria or ensuring there's a unique match for the uninstall process.
          $targetEntry = $pwshEntries | Select-Object -First 1

@MariusStorhaug MariusStorhaug merged commit 7da1f59 into main Jun 14, 2025
23 checks passed
@MariusStorhaug MariusStorhaug deleted the copilot/fix-3 branch June 14, 2025 22:07
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.

🩹 [Patch]: Ensure downgrade when requested on Windows
2 participants