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

Export command for winget settings. #2719

Merged
merged 11 commits into from
Dec 13, 2022

Conversation

msftrubengu
Copy link
Contributor

@msftrubengu msftrubengu commented Nov 23, 2022

Add new command for winget settings export. This command will report the value of the winget admin settings formatted as json, as well as the path of the user settings file.

C:\Windows\System32>wingetdev settings export
{"adminSettings":{"BypassCertificatePinningForMicrosoftStore":false,"LocalManifestFiles":true},"userSettingsFile":"%LOCALAPPDATA%\\Packages\\WinGetDevCLI_8wekyb3d8bbwe\\LocalState\\settings.json"}

C:\Windows\System32>winget.exe settings export
{"adminSettings":{"BypassCertificatePinningForMicrosoftStore":false,"LocalManifestFiles":true},"userSettingsFile":%LOCALAPPDATA%\\Microsoft\\WinGet\\Settings\\defaultState\\settings.json"}

Also adding the user settings json path in winget --info for completeness.

In preparation of #2697

Microsoft Reviewers: Open in CodeFlow

@msftrubengu msftrubengu requested a review from a team as a code owner November 23, 2022 00:38

void ExportAdminSettings(Execution::Context& context)
{
AdminSetting settings[] =
Copy link
Member

Choose a reason for hiding this comment

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

This would be better if there were a Max enum value and we could just enumerate for (i = firstValidSetting; i < AdminSetting::Max; ++i) so that any future settings are automatically included.

void SettingsExportCommand::ExecuteInternal(Execution::Context& context) const
{
context <<
Workflow::EnsureRunningAsAdmin <<
Copy link
Contributor

Choose a reason for hiding this comment

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

Workflow::EnsureRunningAsAdmin

Just curious is there a particular reason to require admin for export? Exporting seems harmless to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no real reason. Removing.

{
AdminSettings()
{
root["adminSettings"] = Json::ValueType::objectValue;
Copy link
Contributor

Choose a reason for hiding this comment

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

root["adminSettings"] = Json::ValueType::objectValue;

Is the exported settings to be imported in Powershell DSC? Do we need a schema version or it's unlikely to change in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For DSC... not entirely. The admin settings resource will take a hashtable with something really similar to value of the adminSettings. We just needed a way to expose it without reading registry keys.

Also, because reasons (mostly testing and not having to special case powershell) I'm adding the path of the local user settings file to winget settings export . Also winget --info for completeness.

But yes, I'm going to add a new schema.

@github-actions

This comment has been minimized.

@msftrubengu msftrubengu changed the title Export command for administrator settings. Export command for winget settings. Dec 8, 2022
@github-actions

This comment has been minimized.

@@ -193,6 +193,7 @@ namespace AppInstaller::CLI
};

info << std::endl << Resource::String::Logs << ": "_liv << Runtime::GetPathTo(Runtime::PathName::DefaultLogLocationForDisplay).u8string() << std::endl;
info << std::endl << Resource::String::UserSettings << ": "_liv << Runtime::GetPathTo(Runtime::PathName::UserSettingsFileLocation).u8string() << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

info << std::endl << Resource::String::UserSettings << ": "_liv << Runtime::GetPathTo(Runtime::PathName::UserSettingsFileLocation).u8string() << std::endl;

We may need to remember to update this one when #2454 is merged

Copy link
Contributor

@yao-msft yao-msft left a comment

Choose a reason for hiding this comment

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

:shipit:

@msftrubengu msftrubengu merged commit 050056a into microsoft:master Dec 13, 2022
@msftrubengu msftrubengu deleted the exportadminsettings 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.

3 participants