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

Implement WinGetUserSettings cmdlets #2776

Merged
merged 15 commits into from
Jan 6, 2023

Conversation

msftrubengu
Copy link
Contributor

@msftrubengu msftrubengu commented Dec 16, 2022

This PR implements 3 cmdlets:

  • Get-WinGetUserSettings - returns the contents of the settings.json file. If the file is not valid json, throws UserSettingsReadException.
  • Set-WinGetUserSettings - writes the serialized input hashtable into the settings.json. If the Merge option is set, merges the current settings.json with the input given, otherwise overwrites the current settings with input settings. If Merge is used and settings.json is not valid json throws UserSettingsReadException.
  • Test-WinGetUserSettings - compares the given input settings with the current settings.json. If the IgnoreNotSet option is set, makes a partial comparison where it ignores properties not set in the input that are present in settings.json, otherwise make a full comparison.

The settings file is read via winget settings export, so these commands require a newer version of winget. In the near future, I'll add a new attribute in each cmdlet that specify the minimum winget version that is required.

To be testable, the cmdlets follow the similar patter to pick which version of winget to use via USE_PROD_CLSIDS. I'll change the name to something more general in a future PR. We also need to modify the crescendo generated functions to point to wingetdev without it being that intrusive.

I also tried to move the PowerShell E2E to use PowerShell host to make better tests, but I got some issues and I kind of gave up for now to keep the code flowing. The user settings cmdlets tests use PowerShell host though. However, the Microsoft.WinGet.Client project cannot be references by AppInstallerCLIE2ETests because PowerShell host will complain while trying to load the module. My guess is that there's some conflict loading the Microsoft.WinGet.Client.dll

Also, made more general improvements to Microsoft.WinGet.Client.

Related to #2697

Microsoft Reviewers: Open in CodeFlow

@msftrubengu msftrubengu requested a review from a team as a code owner December 16, 2022 19:19
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@msftrubengu msftrubengu merged commit f426c9a into microsoft:master Jan 6, 2023
@msftrubengu msftrubengu deleted the da_usersettings branch January 6, 2023 18:26
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.

2 participants