Re-apply PR #2271 & Fix For Loop in 'Install-WinUtilProgramWinget' Private Function #2396
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
PR #2271 had a major flaw of installing some un-wanted apps from MS Store (as described in issue #2385), It was temporarily solved by reverting its changes in commit c903631.
This PR tries to solve the underlying logical error that PR #2271 had, which was trying to access out-of-bound memory (a common off-by-one error), where PowerShell would return
$null
(meaning the item this function has requested from$ProgramsToInstall
Object Array is an empty item), which will make the Program ID (the input) an invalid value, causing un-expected behaviors from WinGet (The Package Manager), like installing the newest released app from MS Store.Testing
After further testing (tried it with all sort of combinations, one app, multiple applications, some are installed already, some had to upgrade, etc...), the updated code is working as expected.
Impact
At the end.. it won't be noticeable by the end user, as the only thing this PR (and #2271 PR) tried to solve is the terminal progress bar (it was broken in original
ForEach
loop, off by one in #2271 PR, and in this PR it's working as expected).So generally speaking.. User won't really notice this issue (The progress bar being off or broken), but it would be nice to fix this if possible.
Issue related to PR
Additional Information
If you've the time to spare, please consider testing these changes, thanks in advance 😄
Checklist