Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2f4391b
Add admin setting for enabling proxy
florelis Feb 15, 2024
b7f8153
Add proxy argument
florelis Feb 16, 2024
b2d9f31
Add group policy
florelis Feb 17, 2024
d729041
Fix bad name copy
florelis Feb 17, 2024
426a5f3
Add policy for default proxy
florelis Feb 21, 2024
f795ce2
Add proxy to context
florelis Feb 21, 2024
4d73e74
Add experimental feature
florelis Feb 22, 2024
59b0a5f
Pass proxy info to some places it is needed
florelis Feb 23, 2024
d002528
Add proxy info to sources
florelis Feb 23, 2024
7caaa86
Add admin setting for default proxy
florelis Feb 24, 2024
1a588b0
Use admin setting for proxy
florelis Feb 24, 2024
682e07e
Add to info, export
florelis Feb 24, 2024
2f843c0
Add proxy to settings schema experimental features
florelis Feb 26, 2024
e984f7f
Typo
florelis Feb 26, 2024
f5fa5f1
Merge branch 'master' into proxy
florelis Feb 26, 2024
284a1ce
Fix id
florelis Feb 26, 2024
17264b7
missing ;
florelis Feb 26, 2024
8a11d7c
Use existing httpclienthelper
florelis Feb 27, 2024
3172238
Fix string id
florelis Feb 27, 2024
2a2def3
Merge branch 'master' into proxy
florelis Feb 27, 2024
2e065e6
Make proxy settings global
florelis Feb 29, 2024
48872d5
Make proxy arguments common
florelis Feb 29, 2024
87dba88
Update doc/admx/en-US/DesktopAppInstaller.adml
florelis Mar 11, 2024
d20d685
Fix set default proxy
florelis Mar 11, 2024
0d92842
Move setting proxy to HttpClientHelper constructor
florelis Mar 11, 2024
84fb0da
Add to settings.md
florelis Mar 11, 2024
193d2eb
Update settings schema
florelis Mar 11, 2024
25facf1
Fix arg name
florelis Mar 11, 2024
e0fdcf7
Reset bool admin settings
florelis Mar 11, 2024
3d8f87a
LocIndString
florelis Mar 11, 2024
48d2ab5
Update src/AppInstallerCLICore/Commands/SettingsCommand.cpp
florelis Mar 14, 2024
97e9415
Update src/AppInstallerCLICore/Workflows/SettingsFlow.cpp
florelis Mar 14, 2024
ce47cf5
PR suggestion
florelis Mar 14, 2024
fb18813
Missing )
florelis Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -312,3 +312,14 @@ You can enable the feature as shown below.
"configuration03": true
},
```

### proxy

This feature enables the use of web proxies.
You can enable the feature as shown below.

```json
"experimentalFeatures": {
"proxy": true
},
```
17 changes: 17 additions & 0 deletions doc/admx/DesktopAppInstaller.admx
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,5 +166,22 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="EnableWindowsPackageManagerProxyCommandLineOptions" class="Machine" displayName="$(string.EnableWindowsPackageManagerProxyCommandLineOptions)" explainText="$(string.EnableWindowsPackageManagerProxyCommandLineOptionsExplanation)" key="Software\Policies\Microsoft\Windows\AppInstaller" valueName="EnableWindowsPackageManagerProxyCommandLineOptions">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="WindowsPackageManagerDefaultProxy" class="Machine" displayName="$(string.WindowsPackageManagerDefaultProxy)" explainText="$(string.WindowsPackageManagerDefaultProxyExplanation)" presentation="$(presentation.WindowsPackageManagerDefaultProxy)" key="Software\Policies\Microsoft\Windows\AppInstaller">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<elements>
<text id="WindowsPackageManagerDefaultProxy" valueName="DefaultProxy" />
</elements>
</policy>
</policies>
</policyDefinitions>
20 changes: 19 additions & 1 deletion doc/admx/en-US/DesktopAppInstaller.adml
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,7 +100,7 @@ If you disable or do not configure this setting, users will not be able to insta

If you disable this policy, users will not be able execute the Windows Package Manager CLI, and PowerShell cmdlets.

If you enable, or do not configuring this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).
If you enable, or do not configure this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).

This policy does not override the “Enable App Installer” policy.</string>
<string id="EnableWindowsPackageManagerConfiguration">Enable Windows Package Manager Configuration</string>
Expand All@@ -109,6 +109,19 @@ If you disable or do not configure this setting, users will not be able to insta
If you enable or do not configure this setting, users will be able to use the Windows Package Manager configuration feature.

If you disable this setting, users will not be able to use the Windows Package Manager configuration feature.</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptions">Enable Windows Package Manager Proxy command line options</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptionsExplanation">
This policy controls whether the Windows Package Manager usage of proxy can be configured by users through the command line.

If you enable this setting, users will be able to configure the Windows Package Manager's use of proxy through the command line.

If you disable or do not configure this setting, users will not be able to to configure the Windows Package Manager's use of proxy through the command line.</string>
<string id="WindowsPackageManagerDefaultProxy">Set Windows Package Manager Default Proxy</string>
<string id="WindowsPackageManagerDefaultProxyExplanation">This policy controls the default proxy used by the Windows Package Manager.

If you disable or do not configure this setting, no proxy will be used by default.

If you enable this setting, the specified proxy will be used by default.</string>
</stringTable>
<presentationTable>
<presentation id="SourceAutoUpdateInterval">
Expand All@@ -120,6 +133,11 @@ If you disable this setting, users will not be able to use the Windows Package M
<presentation id="AllowedSources">
<listBox refId="AllowedSources" required="false">Allowed Sources: </listBox>
</presentation>
<presentation id="WindowsPackageManagerDefaultProxy">
<textBox refId="WindowsPackageManagerDefaultProxy">
<label>Default Proxy</label>
</textBox>
</presentation>
</presentationTable>
</resources>
</policyDefinitionResources>
20 changes: 19 additions & 1 deletion schemas/JSON/settings/settings.export.schema.0.1.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,26 @@
"description": "Enable installing local manifests.",
"type": "boolean",
"default": false
},
"InstallerHashOverride": {
"description": "Enable overriding installer hash validation.",
"type": "boolean",
"default": false
},
"LocalArchiveMalwareScanOverride": {
"description": "Enable overriding malware scan for local archives.",
"type": "boolean",
"default": false
},
"ProxyCommandLineOptions": {
"description": "Enable using command line options for proxy.",
"type": "boolean",
"default": false
},
"DefaultProxy": {
"description": "Default proxy.",
"type": "string"
}
}
},
"UserSettingsFile": {
"description": "Path for the winget's user settings file.",
Expand Down
9 changes: 7 additions & 2 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,8 +266,13 @@
"type": "boolean",
"default": false
},
"configuration": {
"description": "Enable support for configuration",
"configuration03": {
"description": "Enable support for configuration schema 0.3",
"type": "boolean",
"default": false
},
"proxy": {
Comment thread
florelis marked this conversation as resolved.
"description": "Enable support for proxies",
"type": "boolean",
"default": false
}
Expand Down
21 changes: 18 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,6 +151,10 @@ namespace AppInstaller::CLI
return { type, "enable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::AdminSettingDisable:
return { type, "disable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::SettingName:
return { type, "setting"_liv };
case Execution::Args::Type::SettingValue:
return { type, "value"_liv };

// Upgrade command
case Execution::Args::Type::All:
Expand DownExpand Up@@ -233,6 +237,11 @@ namespace AppInstaller::CLI
case Execution::Args::Type::AcceptSourceAgreements:
return { type, "accept-source-agreements"_liv, ArgTypeCategory::ExtendedSource };

case Execution::Args::Type::Proxy:
return { type, "proxy"_liv, ArgTypeCategory::CopyValueToSubContext, ArgTypeExclusiveSet::Proxy };
case Execution::Args::Type::NoProxy:
return { type, "no-proxy"_liv, ArgTypeCategory::CopyFlagToSubContext, ArgTypeExclusiveSet::Proxy };

case Execution::Args::Type::ToolVersion:
return { type, "version"_liv, 'v' };

Expand DownExpand Up@@ -268,7 +277,7 @@ namespace AppInstaller::CLI
case Args::Type::MultiQuery:
return Argument{ type, Resource::String::MultiQueryArgumentDescription, ArgumentType::Positional }.SetCountLimit(128);
case Args::Type::Manifest:
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::AdminSetting::LocalManifestFiles };
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::BoolAdminSetting::LocalManifestFiles };
case Args::Type::Id:
return Argument{ type, Resource::String::IdArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help };
case Args::Type::Name:
Expand DownExpand Up@@ -308,7 +317,7 @@ namespace AppInstaller::CLI
case Args::Type::InstallLocation:
return Argument{ type, Resource::String::LocationArgumentDescription, ArgumentType::Standard };
case Args::Type::HashOverride:
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::AdminSetting::InstallerHashOverride };
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::BoolAdminSetting::InstallerHashOverride };
case Args::Type::AcceptPackageAgreements:
return Argument{ type, Resource::String::AcceptPackageAgreementsArgumentDescription, ArgumentType::Flag };
case Args::Type::NoUpgrade:
Expand All@@ -324,7 +333,7 @@ namespace AppInstaller::CLI
case Args::Type::SkipDependencies:
return Argument{ type, Resource::String::SkipDependenciesArgumentDescription, ArgumentType::Flag, false };
case Args::Type::IgnoreLocalArchiveMalwareScan:
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::AdminSetting::LocalArchiveMalwareScanOverride };
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::BoolAdminSetting::LocalArchiveMalwareScanOverride };
case Args::Type::SourceName:
return Argument{ type, Resource::String::SourceNameArgumentDescription, ArgumentType::Positional, false };
case Args::Type::SourceArg:
Expand DownExpand Up@@ -379,6 +388,10 @@ namespace AppInstaller::CLI
return Argument{ type, Resource::String::AllowRebootArgumentDescription, ArgumentType::Flag };
case Args::Type::IgnoreResumeLimit:
return Argument{ type, Resource::String::IgnoreResumeLimitArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Resume };
case Args::Type::Proxy:
return Argument{ type, Resource::String::ProxyArgumentDescription, ArgumentType::Standard, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
case Args::Type::NoProxy:
return Argument{ type, Resource::String::NoProxyArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
default:
THROW_HR(E_UNEXPECTED);
}
Expand All@@ -394,6 +407,8 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
args.emplace_back(Args::Type::DisableInteractivity, Resource::String::DisableInteractivityArgumentDescription, ArgumentType::Flag, false);
args.push_back(ForType(Args::Type::Proxy));
args.push_back(ForType(Args::Type::NoProxy));
}

std::string Argument::GetUsageString() const
Expand Down
12 changes: 8 additions & 4 deletions src/AppInstallerCLICore/Argument.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,7 @@ namespace AppInstaller::CLI
PurgePreserve = 0x4,
PinType = 0x8,
StubType = 0x10,
Proxy = 0x20,

// This must always be at the end
Max
Expand DownExpand Up@@ -211,7 +212,7 @@ namespace AppInstaller::CLI
Argument::Visibility GetVisibility() const;
Settings::ExperimentalFeature::Feature Feature() const { return m_feature; }
Settings::TogglePolicy::Policy GroupPolicy() const { return m_groupPolicy; }
Settings::AdminSetting AdminSetting() const { return m_adminSetting; }
Settings::BoolAdminSetting AdminSetting() const { return m_adminSetting; }

Argument& SetRequired(bool required) { m_required = required; return *this; }
Argument& SetCountLimit(size_t countLimit) { m_countLimit = countLimit; return *this; }
Expand All@@ -237,12 +238,15 @@ namespace AppInstaller::CLI
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, bool required, Settings::ExperimentalFeature::Feature feature) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_required(required), m_feature(feature) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::ExperimentalFeature::Feature feature, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_feature(feature), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

ArgumentCommon m_argCommon;
Resource::StringId m_desc;
bool m_required = false;
Expand All@@ -251,6 +255,6 @@ namespace AppInstaller::CLI
size_t m_countLimit = 1;
Settings::ExperimentalFeature::Feature m_feature = Settings::ExperimentalFeature::Feature::None;
Settings::TogglePolicy::Policy m_groupPolicy = Settings::TogglePolicy::Policy::None;
Settings::AdminSetting m_adminSetting = Settings::AdminSetting::Unknown;
Settings::BoolAdminSetting m_adminSetting = Settings::BoolAdminSetting::Unknown;
};
}
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Command.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -637,7 +637,7 @@ namespace AppInstaller::CLI
throw GroupPolicyException(arg.GroupPolicy());
}

if (arg.AdminSetting() != AdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
if (arg.AdminSetting() != BoolAdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
{
auto setting = Settings::AdminSettingToString(arg.AdminSetting());
AICLI_LOG(CLI, Error, << "Trying to use argument: " << arg.Name() << " disabled by admin setting " << setting);
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLICore/Commands/DownloadCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,8 +36,8 @@ namespace AppInstaller::CLI
Argument::ForType(Args::Type::CustomHeader),
Argument::ForType(Args::Type::AuthenticationMode),
Argument::ForType(Args::Type::AuthenticationAccount),
Argument::ForType(Execution::Args::Type::AcceptPackageAgreements),
Argument::ForType(Execution::Args::Type::AcceptSourceAgreements),
Argument::ForType(Args::Type::AcceptPackageAgreements),
Argument::ForType(Args::Type::AcceptSourceAgreements),
};
}

Expand Down
10 changes: 9 additions & 1 deletion src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,13 +124,21 @@ namespace AppInstaller::CLI
Execution::TableOutput<2> adminSettingsTable{ context.Reporter, { Resource::String::AdminSettingHeader, Resource::String::StateHeader } };

// Output the admin settings.
for (const auto& setting : Settings::GetAllAdminSettings())
for (const auto& setting : Settings::GetAllBoolAdminSettings())
{
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
Resource::LocString{ IsAdminSettingEnabled(setting) ? Resource::String::StateEnabled : Resource::String::StateDisabled }
});
}
for (const auto& setting : Settings::GetAllStringAdminSettings())
{
auto settingValue = GetAdminSetting(setting);
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
settingValue ? Utility::LocIndString{ settingValue.value() } : Resource::LocString{ Resource::String::StateDisabled }
});
}
adminSettingsTable.Complete();
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Add support for proxies #190 by florelis · Pull Request #4203 · microsoft/winget-cli · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2f4391b
Add admin setting for enabling proxy
florelis Feb 15, 2024
b7f8153
Add proxy argument
florelis Feb 16, 2024
b2d9f31
Add group policy
florelis Feb 17, 2024
d729041
Fix bad name copy
florelis Feb 17, 2024
426a5f3
Add policy for default proxy
florelis Feb 21, 2024
f795ce2
Add proxy to context
florelis Feb 21, 2024
4d73e74
Add experimental feature
florelis Feb 22, 2024
59b0a5f
Pass proxy info to some places it is needed
florelis Feb 23, 2024
d002528
Add proxy info to sources
florelis Feb 23, 2024
7caaa86
Add admin setting for default proxy
florelis Feb 24, 2024
1a588b0
Use admin setting for proxy
florelis Feb 24, 2024
682e07e
Add to info, export
florelis Feb 24, 2024
2f843c0
Add proxy to settings schema experimental features
florelis Feb 26, 2024
e984f7f
Typo
florelis Feb 26, 2024
f5fa5f1
Merge branch 'master' into proxy
florelis Feb 26, 2024
284a1ce
Fix id
florelis Feb 26, 2024
17264b7
missing ;
florelis Feb 26, 2024
8a11d7c
Use existing httpclienthelper
florelis Feb 27, 2024
3172238
Fix string id
florelis Feb 27, 2024
2a2def3
Merge branch 'master' into proxy
florelis Feb 27, 2024
2e065e6
Make proxy settings global
florelis Feb 29, 2024
48872d5
Make proxy arguments common
florelis Feb 29, 2024
87dba88
Update doc/admx/en-US/DesktopAppInstaller.adml
florelis Mar 11, 2024
d20d685
Fix set default proxy
florelis Mar 11, 2024
0d92842
Move setting proxy to HttpClientHelper constructor
florelis Mar 11, 2024
84fb0da
Add to settings.md
florelis Mar 11, 2024
193d2eb
Update settings schema
florelis Mar 11, 2024
25facf1
Fix arg name
florelis Mar 11, 2024
e0fdcf7
Reset bool admin settings
florelis Mar 11, 2024
3d8f87a
LocIndString
florelis Mar 11, 2024
48d2ab5
Update src/AppInstallerCLICore/Commands/SettingsCommand.cpp
florelis Mar 14, 2024
97e9415
Update src/AppInstallerCLICore/Workflows/SettingsFlow.cpp
florelis Mar 14, 2024
ce47cf5
PR suggestion
florelis Mar 14, 2024
fb18813
Missing )
florelis Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -312,3 +312,14 @@ You can enable the feature as shown below.
"configuration03": true
},
```

### proxy

This feature enables the use of web proxies.
You can enable the feature as shown below.

```json
"experimentalFeatures": {
"proxy": true
},
```
17 changes: 17 additions & 0 deletions doc/admx/DesktopAppInstaller.admx
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,5 +166,22 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="EnableWindowsPackageManagerProxyCommandLineOptions" class="Machine" displayName="$(string.EnableWindowsPackageManagerProxyCommandLineOptions)" explainText="$(string.EnableWindowsPackageManagerProxyCommandLineOptionsExplanation)" key="Software\Policies\Microsoft\Windows\AppInstaller" valueName="EnableWindowsPackageManagerProxyCommandLineOptions">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="WindowsPackageManagerDefaultProxy" class="Machine" displayName="$(string.WindowsPackageManagerDefaultProxy)" explainText="$(string.WindowsPackageManagerDefaultProxyExplanation)" presentation="$(presentation.WindowsPackageManagerDefaultProxy)" key="Software\Policies\Microsoft\Windows\AppInstaller">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<elements>
<text id="WindowsPackageManagerDefaultProxy" valueName="DefaultProxy" />
</elements>
</policy>
</policies>
</policyDefinitions>
20 changes: 19 additions & 1 deletion doc/admx/en-US/DesktopAppInstaller.adml
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,7 +100,7 @@ If you disable or do not configure this setting, users will not be able to insta

If you disable this policy, users will not be able execute the Windows Package Manager CLI, and PowerShell cmdlets.

If you enable, or do not configuring this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).
If you enable, or do not configure this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).

This policy does not override the “Enable App Installer” policy.</string>
<string id="EnableWindowsPackageManagerConfiguration">Enable Windows Package Manager Configuration</string>
Expand All@@ -109,6 +109,19 @@ If you disable or do not configure this setting, users will not be able to insta
If you enable or do not configure this setting, users will be able to use the Windows Package Manager configuration feature.

If you disable this setting, users will not be able to use the Windows Package Manager configuration feature.</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptions">Enable Windows Package Manager Proxy command line options</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptionsExplanation">
This policy controls whether the Windows Package Manager usage of proxy can be configured by users through the command line.

If you enable this setting, users will be able to configure the Windows Package Manager's use of proxy through the command line.

If you disable or do not configure this setting, users will not be able to to configure the Windows Package Manager's use of proxy through the command line.</string>
<string id="WindowsPackageManagerDefaultProxy">Set Windows Package Manager Default Proxy</string>
<string id="WindowsPackageManagerDefaultProxyExplanation">This policy controls the default proxy used by the Windows Package Manager.

If you disable or do not configure this setting, no proxy will be used by default.

If you enable this setting, the specified proxy will be used by default.</string>
</stringTable>
<presentationTable>
<presentation id="SourceAutoUpdateInterval">
Expand All@@ -120,6 +133,11 @@ If you disable this setting, users will not be able to use the Windows Package M
<presentation id="AllowedSources">
<listBox refId="AllowedSources" required="false">Allowed Sources: </listBox>
</presentation>
<presentation id="WindowsPackageManagerDefaultProxy">
<textBox refId="WindowsPackageManagerDefaultProxy">
<label>Default Proxy</label>
</textBox>
</presentation>
</presentationTable>
</resources>
</policyDefinitionResources>
20 changes: 19 additions & 1 deletion schemas/JSON/settings/settings.export.schema.0.1.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,26 @@
"description": "Enable installing local manifests.",
"type": "boolean",
"default": false
},
"InstallerHashOverride": {
"description": "Enable overriding installer hash validation.",
"type": "boolean",
"default": false
},
"LocalArchiveMalwareScanOverride": {
"description": "Enable overriding malware scan for local archives.",
"type": "boolean",
"default": false
},
"ProxyCommandLineOptions": {
"description": "Enable using command line options for proxy.",
"type": "boolean",
"default": false
},
"DefaultProxy": {
"description": "Default proxy.",
"type": "string"
}
}
},
"UserSettingsFile": {
"description": "Path for the winget's user settings file.",
Expand Down
9 changes: 7 additions & 2 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,8 +266,13 @@
"type": "boolean",
"default": false
},
"configuration": {
"description": "Enable support for configuration",
"configuration03": {
"description": "Enable support for configuration schema 0.3",
"type": "boolean",
"default": false
},
"proxy": {
Comment thread
florelis marked this conversation as resolved.
"description": "Enable support for proxies",
"type": "boolean",
"default": false
}
Expand Down
21 changes: 18 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,6 +151,10 @@ namespace AppInstaller::CLI
return { type, "enable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::AdminSettingDisable:
return { type, "disable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::SettingName:
return { type, "setting"_liv };
case Execution::Args::Type::SettingValue:
return { type, "value"_liv };

// Upgrade command
case Execution::Args::Type::All:
Expand DownExpand Up@@ -233,6 +237,11 @@ namespace AppInstaller::CLI
case Execution::Args::Type::AcceptSourceAgreements:
return { type, "accept-source-agreements"_liv, ArgTypeCategory::ExtendedSource };

case Execution::Args::Type::Proxy:
return { type, "proxy"_liv, ArgTypeCategory::CopyValueToSubContext, ArgTypeExclusiveSet::Proxy };
case Execution::Args::Type::NoProxy:
return { type, "no-proxy"_liv, ArgTypeCategory::CopyFlagToSubContext, ArgTypeExclusiveSet::Proxy };

case Execution::Args::Type::ToolVersion:
return { type, "version"_liv, 'v' };

Expand DownExpand Up@@ -268,7 +277,7 @@ namespace AppInstaller::CLI
case Args::Type::MultiQuery:
return Argument{ type, Resource::String::MultiQueryArgumentDescription, ArgumentType::Positional }.SetCountLimit(128);
case Args::Type::Manifest:
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::AdminSetting::LocalManifestFiles };
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::BoolAdminSetting::LocalManifestFiles };
case Args::Type::Id:
return Argument{ type, Resource::String::IdArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help };
case Args::Type::Name:
Expand DownExpand Up@@ -308,7 +317,7 @@ namespace AppInstaller::CLI
case Args::Type::InstallLocation:
return Argument{ type, Resource::String::LocationArgumentDescription, ArgumentType::Standard };
case Args::Type::HashOverride:
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::AdminSetting::InstallerHashOverride };
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::BoolAdminSetting::InstallerHashOverride };
case Args::Type::AcceptPackageAgreements:
return Argument{ type, Resource::String::AcceptPackageAgreementsArgumentDescription, ArgumentType::Flag };
case Args::Type::NoUpgrade:
Expand All@@ -324,7 +333,7 @@ namespace AppInstaller::CLI
case Args::Type::SkipDependencies:
return Argument{ type, Resource::String::SkipDependenciesArgumentDescription, ArgumentType::Flag, false };
case Args::Type::IgnoreLocalArchiveMalwareScan:
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::AdminSetting::LocalArchiveMalwareScanOverride };
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::BoolAdminSetting::LocalArchiveMalwareScanOverride };
case Args::Type::SourceName:
return Argument{ type, Resource::String::SourceNameArgumentDescription, ArgumentType::Positional, false };
case Args::Type::SourceArg:
Expand DownExpand Up@@ -379,6 +388,10 @@ namespace AppInstaller::CLI
return Argument{ type, Resource::String::AllowRebootArgumentDescription, ArgumentType::Flag };
case Args::Type::IgnoreResumeLimit:
return Argument{ type, Resource::String::IgnoreResumeLimitArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Resume };
case Args::Type::Proxy:
return Argument{ type, Resource::String::ProxyArgumentDescription, ArgumentType::Standard, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
case Args::Type::NoProxy:
return Argument{ type, Resource::String::NoProxyArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
default:
THROW_HR(E_UNEXPECTED);
}
Expand All@@ -394,6 +407,8 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
args.emplace_back(Args::Type::DisableInteractivity, Resource::String::DisableInteractivityArgumentDescription, ArgumentType::Flag, false);
args.push_back(ForType(Args::Type::Proxy));
args.push_back(ForType(Args::Type::NoProxy));
}

std::string Argument::GetUsageString() const
Expand Down
12 changes: 8 additions & 4 deletions src/AppInstallerCLICore/Argument.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,7 @@ namespace AppInstaller::CLI
PurgePreserve = 0x4,
PinType = 0x8,
StubType = 0x10,
Proxy = 0x20,

// This must always be at the end
Max
Expand DownExpand Up@@ -211,7 +212,7 @@ namespace AppInstaller::CLI
Argument::Visibility GetVisibility() const;
Settings::ExperimentalFeature::Feature Feature() const { return m_feature; }
Settings::TogglePolicy::Policy GroupPolicy() const { return m_groupPolicy; }
Settings::AdminSetting AdminSetting() const { return m_adminSetting; }
Settings::BoolAdminSetting AdminSetting() const { return m_adminSetting; }

Argument& SetRequired(bool required) { m_required = required; return *this; }
Argument& SetCountLimit(size_t countLimit) { m_countLimit = countLimit; return *this; }
Expand All@@ -237,12 +238,15 @@ namespace AppInstaller::CLI
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, bool required, Settings::ExperimentalFeature::Feature feature) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_required(required), m_feature(feature) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::ExperimentalFeature::Feature feature, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_feature(feature), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

ArgumentCommon m_argCommon;
Resource::StringId m_desc;
bool m_required = false;
Expand All@@ -251,6 +255,6 @@ namespace AppInstaller::CLI
size_t m_countLimit = 1;
Settings::ExperimentalFeature::Feature m_feature = Settings::ExperimentalFeature::Feature::None;
Settings::TogglePolicy::Policy m_groupPolicy = Settings::TogglePolicy::Policy::None;
Settings::AdminSetting m_adminSetting = Settings::AdminSetting::Unknown;
Settings::BoolAdminSetting m_adminSetting = Settings::BoolAdminSetting::Unknown;
};
}
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Command.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -637,7 +637,7 @@ namespace AppInstaller::CLI
throw GroupPolicyException(arg.GroupPolicy());
}

if (arg.AdminSetting() != AdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
if (arg.AdminSetting() != BoolAdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
{
auto setting = Settings::AdminSettingToString(arg.AdminSetting());
AICLI_LOG(CLI, Error, << "Trying to use argument: " << arg.Name() << " disabled by admin setting " << setting);
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLICore/Commands/DownloadCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,8 +36,8 @@ namespace AppInstaller::CLI
Argument::ForType(Args::Type::CustomHeader),
Argument::ForType(Args::Type::AuthenticationMode),
Argument::ForType(Args::Type::AuthenticationAccount),
Argument::ForType(Execution::Args::Type::AcceptPackageAgreements),
Argument::ForType(Execution::Args::Type::AcceptSourceAgreements),
Argument::ForType(Args::Type::AcceptPackageAgreements),
Argument::ForType(Args::Type::AcceptSourceAgreements),
};
}

Expand Down
10 changes: 9 additions & 1 deletion src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,13 +124,21 @@ namespace AppInstaller::CLI
Execution::TableOutput<2> adminSettingsTable{ context.Reporter, { Resource::String::AdminSettingHeader, Resource::String::StateHeader } };

// Output the admin settings.
for (const auto& setting : Settings::GetAllAdminSettings())
for (const auto& setting : Settings::GetAllBoolAdminSettings())
{
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
Resource::LocString{ IsAdminSettingEnabled(setting) ? Resource::String::StateEnabled : Resource::String::StateDisabled }
});
}
for (const auto& setting : Settings::GetAllStringAdminSettings())
{
auto settingValue = GetAdminSetting(setting);
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
settingValue ? Utility::LocIndString{ settingValue.value() } : Resource::LocString{ Resource::String::StateDisabled }
});
}
adminSettingsTable.Complete();
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add support for proxies #190 by florelis · Pull Request #4203 · microsoft/winget-cli · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2f4391b
Add admin setting for enabling proxy
florelis Feb 15, 2024
b7f8153
Add proxy argument
florelis Feb 16, 2024
b2d9f31
Add group policy
florelis Feb 17, 2024
d729041
Fix bad name copy
florelis Feb 17, 2024
426a5f3
Add policy for default proxy
florelis Feb 21, 2024
f795ce2
Add proxy to context
florelis Feb 21, 2024
4d73e74
Add experimental feature
florelis Feb 22, 2024
59b0a5f
Pass proxy info to some places it is needed
florelis Feb 23, 2024
d002528
Add proxy info to sources
florelis Feb 23, 2024
7caaa86
Add admin setting for default proxy
florelis Feb 24, 2024
1a588b0
Use admin setting for proxy
florelis Feb 24, 2024
682e07e
Add to info, export
florelis Feb 24, 2024
2f843c0
Add proxy to settings schema experimental features
florelis Feb 26, 2024
e984f7f
Typo
florelis Feb 26, 2024
f5fa5f1
Merge branch 'master' into proxy
florelis Feb 26, 2024
284a1ce
Fix id
florelis Feb 26, 2024
17264b7
missing ;
florelis Feb 26, 2024
8a11d7c
Use existing httpclienthelper
florelis Feb 27, 2024
3172238
Fix string id
florelis Feb 27, 2024
2a2def3
Merge branch 'master' into proxy
florelis Feb 27, 2024
2e065e6
Make proxy settings global
florelis Feb 29, 2024
48872d5
Make proxy arguments common
florelis Feb 29, 2024
87dba88
Update doc/admx/en-US/DesktopAppInstaller.adml
florelis Mar 11, 2024
d20d685
Fix set default proxy
florelis Mar 11, 2024
0d92842
Move setting proxy to HttpClientHelper constructor
florelis Mar 11, 2024
84fb0da
Add to settings.md
florelis Mar 11, 2024
193d2eb
Update settings schema
florelis Mar 11, 2024
25facf1
Fix arg name
florelis Mar 11, 2024
e0fdcf7
Reset bool admin settings
florelis Mar 11, 2024
3d8f87a
LocIndString
florelis Mar 11, 2024
48d2ab5
Update src/AppInstallerCLICore/Commands/SettingsCommand.cpp
florelis Mar 14, 2024
97e9415
Update src/AppInstallerCLICore/Workflows/SettingsFlow.cpp
florelis Mar 14, 2024
ce47cf5
PR suggestion
florelis Mar 14, 2024
fb18813
Missing )
florelis Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -312,3 +312,14 @@ You can enable the feature as shown below.
"configuration03": true
},
```

### proxy

This feature enables the use of web proxies.
You can enable the feature as shown below.

```json
"experimentalFeatures": {
"proxy": true
},
```
17 changes: 17 additions & 0 deletions doc/admx/DesktopAppInstaller.admx
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,5 +166,22 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="EnableWindowsPackageManagerProxyCommandLineOptions" class="Machine" displayName="$(string.EnableWindowsPackageManagerProxyCommandLineOptions)" explainText="$(string.EnableWindowsPackageManagerProxyCommandLineOptionsExplanation)" key="Software\Policies\Microsoft\Windows\AppInstaller" valueName="EnableWindowsPackageManagerProxyCommandLineOptions">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="WindowsPackageManagerDefaultProxy" class="Machine" displayName="$(string.WindowsPackageManagerDefaultProxy)" explainText="$(string.WindowsPackageManagerDefaultProxyExplanation)" presentation="$(presentation.WindowsPackageManagerDefaultProxy)" key="Software\Policies\Microsoft\Windows\AppInstaller">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<elements>
<text id="WindowsPackageManagerDefaultProxy" valueName="DefaultProxy" />
</elements>
</policy>
</policies>
</policyDefinitions>
20 changes: 19 additions & 1 deletion doc/admx/en-US/DesktopAppInstaller.adml
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,7 +100,7 @@ If you disable or do not configure this setting, users will not be able to insta

If you disable this policy, users will not be able execute the Windows Package Manager CLI, and PowerShell cmdlets.

If you enable, or do not configuring this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).
If you enable, or do not configure this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).

This policy does not override the “Enable App Installer” policy.</string>
<string id="EnableWindowsPackageManagerConfiguration">Enable Windows Package Manager Configuration</string>
Expand All@@ -109,6 +109,19 @@ If you disable or do not configure this setting, users will not be able to insta
If you enable or do not configure this setting, users will be able to use the Windows Package Manager configuration feature.

If you disable this setting, users will not be able to use the Windows Package Manager configuration feature.</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptions">Enable Windows Package Manager Proxy command line options</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptionsExplanation">
This policy controls whether the Windows Package Manager usage of proxy can be configured by users through the command line.

If you enable this setting, users will be able to configure the Windows Package Manager's use of proxy through the command line.

If you disable or do not configure this setting, users will not be able to to configure the Windows Package Manager's use of proxy through the command line.</string>
<string id="WindowsPackageManagerDefaultProxy">Set Windows Package Manager Default Proxy</string>
<string id="WindowsPackageManagerDefaultProxyExplanation">This policy controls the default proxy used by the Windows Package Manager.

If you disable or do not configure this setting, no proxy will be used by default.

If you enable this setting, the specified proxy will be used by default.</string>
</stringTable>
<presentationTable>
<presentation id="SourceAutoUpdateInterval">
Expand All@@ -120,6 +133,11 @@ If you disable this setting, users will not be able to use the Windows Package M
<presentation id="AllowedSources">
<listBox refId="AllowedSources" required="false">Allowed Sources: </listBox>
</presentation>
<presentation id="WindowsPackageManagerDefaultProxy">
<textBox refId="WindowsPackageManagerDefaultProxy">
<label>Default Proxy</label>
</textBox>
</presentation>
</presentationTable>
</resources>
</policyDefinitionResources>
20 changes: 19 additions & 1 deletion schemas/JSON/settings/settings.export.schema.0.1.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,26 @@
"description": "Enable installing local manifests.",
"type": "boolean",
"default": false
},
"InstallerHashOverride": {
"description": "Enable overriding installer hash validation.",
"type": "boolean",
"default": false
},
"LocalArchiveMalwareScanOverride": {
"description": "Enable overriding malware scan for local archives.",
"type": "boolean",
"default": false
},
"ProxyCommandLineOptions": {
"description": "Enable using command line options for proxy.",
"type": "boolean",
"default": false
},
"DefaultProxy": {
"description": "Default proxy.",
"type": "string"
}
}
},
"UserSettingsFile": {
"description": "Path for the winget's user settings file.",
Expand Down
9 changes: 7 additions & 2 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,8 +266,13 @@
"type": "boolean",
"default": false
},
"configuration": {
"description": "Enable support for configuration",
"configuration03": {
"description": "Enable support for configuration schema 0.3",
"type": "boolean",
"default": false
},
"proxy": {
Comment thread
florelis marked this conversation as resolved.
"description": "Enable support for proxies",
"type": "boolean",
"default": false
}
Expand Down
21 changes: 18 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,6 +151,10 @@ namespace AppInstaller::CLI
return { type, "enable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::AdminSettingDisable:
return { type, "disable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::SettingName:
return { type, "setting"_liv };
case Execution::Args::Type::SettingValue:
return { type, "value"_liv };

// Upgrade command
case Execution::Args::Type::All:
Expand DownExpand Up@@ -233,6 +237,11 @@ namespace AppInstaller::CLI
case Execution::Args::Type::AcceptSourceAgreements:
return { type, "accept-source-agreements"_liv, ArgTypeCategory::ExtendedSource };

case Execution::Args::Type::Proxy:
return { type, "proxy"_liv, ArgTypeCategory::CopyValueToSubContext, ArgTypeExclusiveSet::Proxy };
case Execution::Args::Type::NoProxy:
return { type, "no-proxy"_liv, ArgTypeCategory::CopyFlagToSubContext, ArgTypeExclusiveSet::Proxy };

case Execution::Args::Type::ToolVersion:
return { type, "version"_liv, 'v' };

Expand DownExpand Up@@ -268,7 +277,7 @@ namespace AppInstaller::CLI
case Args::Type::MultiQuery:
return Argument{ type, Resource::String::MultiQueryArgumentDescription, ArgumentType::Positional }.SetCountLimit(128);
case Args::Type::Manifest:
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::AdminSetting::LocalManifestFiles };
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::BoolAdminSetting::LocalManifestFiles };
case Args::Type::Id:
return Argument{ type, Resource::String::IdArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help };
case Args::Type::Name:
Expand DownExpand Up@@ -308,7 +317,7 @@ namespace AppInstaller::CLI
case Args::Type::InstallLocation:
return Argument{ type, Resource::String::LocationArgumentDescription, ArgumentType::Standard };
case Args::Type::HashOverride:
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::AdminSetting::InstallerHashOverride };
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::BoolAdminSetting::InstallerHashOverride };
case Args::Type::AcceptPackageAgreements:
return Argument{ type, Resource::String::AcceptPackageAgreementsArgumentDescription, ArgumentType::Flag };
case Args::Type::NoUpgrade:
Expand All@@ -324,7 +333,7 @@ namespace AppInstaller::CLI
case Args::Type::SkipDependencies:
return Argument{ type, Resource::String::SkipDependenciesArgumentDescription, ArgumentType::Flag, false };
case Args::Type::IgnoreLocalArchiveMalwareScan:
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::AdminSetting::LocalArchiveMalwareScanOverride };
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::BoolAdminSetting::LocalArchiveMalwareScanOverride };
case Args::Type::SourceName:
return Argument{ type, Resource::String::SourceNameArgumentDescription, ArgumentType::Positional, false };
case Args::Type::SourceArg:
Expand DownExpand Up@@ -379,6 +388,10 @@ namespace AppInstaller::CLI
return Argument{ type, Resource::String::AllowRebootArgumentDescription, ArgumentType::Flag };
case Args::Type::IgnoreResumeLimit:
return Argument{ type, Resource::String::IgnoreResumeLimitArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Resume };
case Args::Type::Proxy:
return Argument{ type, Resource::String::ProxyArgumentDescription, ArgumentType::Standard, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
case Args::Type::NoProxy:
return Argument{ type, Resource::String::NoProxyArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
default:
THROW_HR(E_UNEXPECTED);
}
Expand All@@ -394,6 +407,8 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
args.emplace_back(Args::Type::DisableInteractivity, Resource::String::DisableInteractivityArgumentDescription, ArgumentType::Flag, false);
args.push_back(ForType(Args::Type::Proxy));
args.push_back(ForType(Args::Type::NoProxy));
}

std::string Argument::GetUsageString() const
Expand Down
12 changes: 8 additions & 4 deletions src/AppInstallerCLICore/Argument.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,7 @@ namespace AppInstaller::CLI
PurgePreserve = 0x4,
PinType = 0x8,
StubType = 0x10,
Proxy = 0x20,

// This must always be at the end
Max
Expand DownExpand Up@@ -211,7 +212,7 @@ namespace AppInstaller::CLI
Argument::Visibility GetVisibility() const;
Settings::ExperimentalFeature::Feature Feature() const { return m_feature; }
Settings::TogglePolicy::Policy GroupPolicy() const { return m_groupPolicy; }
Settings::AdminSetting AdminSetting() const { return m_adminSetting; }
Settings::BoolAdminSetting AdminSetting() const { return m_adminSetting; }

Argument& SetRequired(bool required) { m_required = required; return *this; }
Argument& SetCountLimit(size_t countLimit) { m_countLimit = countLimit; return *this; }
Expand All@@ -237,12 +238,15 @@ namespace AppInstaller::CLI
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, bool required, Settings::ExperimentalFeature::Feature feature) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_required(required), m_feature(feature) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::ExperimentalFeature::Feature feature, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_feature(feature), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

ArgumentCommon m_argCommon;
Resource::StringId m_desc;
bool m_required = false;
Expand All@@ -251,6 +255,6 @@ namespace AppInstaller::CLI
size_t m_countLimit = 1;
Settings::ExperimentalFeature::Feature m_feature = Settings::ExperimentalFeature::Feature::None;
Settings::TogglePolicy::Policy m_groupPolicy = Settings::TogglePolicy::Policy::None;
Settings::AdminSetting m_adminSetting = Settings::AdminSetting::Unknown;
Settings::BoolAdminSetting m_adminSetting = Settings::BoolAdminSetting::Unknown;
};
}
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Command.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -637,7 +637,7 @@ namespace AppInstaller::CLI
throw GroupPolicyException(arg.GroupPolicy());
}

if (arg.AdminSetting() != AdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
if (arg.AdminSetting() != BoolAdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
{
auto setting = Settings::AdminSettingToString(arg.AdminSetting());
AICLI_LOG(CLI, Error, << "Trying to use argument: " << arg.Name() << " disabled by admin setting " << setting);
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLICore/Commands/DownloadCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,8 +36,8 @@ namespace AppInstaller::CLI
Argument::ForType(Args::Type::CustomHeader),
Argument::ForType(Args::Type::AuthenticationMode),
Argument::ForType(Args::Type::AuthenticationAccount),
Argument::ForType(Execution::Args::Type::AcceptPackageAgreements),
Argument::ForType(Execution::Args::Type::AcceptSourceAgreements),
Argument::ForType(Args::Type::AcceptPackageAgreements),
Argument::ForType(Args::Type::AcceptSourceAgreements),
};
}

Expand Down
10 changes: 9 additions & 1 deletion src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,13 +124,21 @@ namespace AppInstaller::CLI
Execution::TableOutput<2> adminSettingsTable{ context.Reporter, { Resource::String::AdminSettingHeader, Resource::String::StateHeader } };

// Output the admin settings.
for (const auto& setting : Settings::GetAllAdminSettings())
for (const auto& setting : Settings::GetAllBoolAdminSettings())
{
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
Resource::LocString{ IsAdminSettingEnabled(setting) ? Resource::String::StateEnabled : Resource::String::StateDisabled }
});
}
for (const auto& setting : Settings::GetAllStringAdminSettings())
{
auto settingValue = GetAdminSetting(setting);
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
settingValue ? Utility::LocIndString{ settingValue.value() } : Resource::LocString{ Resource::String::StateDisabled }
});
}
adminSettingsTable.Complete();
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add support for proxies #190 by florelis · Pull Request #4203 · microsoft/winget-cli · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2f4391b
Add admin setting for enabling proxy
florelis Feb 15, 2024
b7f8153
Add proxy argument
florelis Feb 16, 2024
b2d9f31
Add group policy
florelis Feb 17, 2024
d729041
Fix bad name copy
florelis Feb 17, 2024
426a5f3
Add policy for default proxy
florelis Feb 21, 2024
f795ce2
Add proxy to context
florelis Feb 21, 2024
4d73e74
Add experimental feature
florelis Feb 22, 2024
59b0a5f
Pass proxy info to some places it is needed
florelis Feb 23, 2024
d002528
Add proxy info to sources
florelis Feb 23, 2024
7caaa86
Add admin setting for default proxy
florelis Feb 24, 2024
1a588b0
Use admin setting for proxy
florelis Feb 24, 2024
682e07e
Add to info, export
florelis Feb 24, 2024
2f843c0
Add proxy to settings schema experimental features
florelis Feb 26, 2024
e984f7f
Typo
florelis Feb 26, 2024
f5fa5f1
Merge branch 'master' into proxy
florelis Feb 26, 2024
284a1ce
Fix id
florelis Feb 26, 2024
17264b7
missing ;
florelis Feb 26, 2024
8a11d7c
Use existing httpclienthelper
florelis Feb 27, 2024
3172238
Fix string id
florelis Feb 27, 2024
2a2def3
Merge branch 'master' into proxy
florelis Feb 27, 2024
2e065e6
Make proxy settings global
florelis Feb 29, 2024
48872d5
Make proxy arguments common
florelis Feb 29, 2024
87dba88
Update doc/admx/en-US/DesktopAppInstaller.adml
florelis Mar 11, 2024
d20d685
Fix set default proxy
florelis Mar 11, 2024
0d92842
Move setting proxy to HttpClientHelper constructor
florelis Mar 11, 2024
84fb0da
Add to settings.md
florelis Mar 11, 2024
193d2eb
Update settings schema
florelis Mar 11, 2024
25facf1
Fix arg name
florelis Mar 11, 2024
e0fdcf7
Reset bool admin settings
florelis Mar 11, 2024
3d8f87a
LocIndString
florelis Mar 11, 2024
48d2ab5
Update src/AppInstallerCLICore/Commands/SettingsCommand.cpp
florelis Mar 14, 2024
97e9415
Update src/AppInstallerCLICore/Workflows/SettingsFlow.cpp
florelis Mar 14, 2024
ce47cf5
PR suggestion
florelis Mar 14, 2024
fb18813
Missing )
florelis Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -312,3 +312,14 @@ You can enable the feature as shown below.
"configuration03": true
},
```

### proxy

This feature enables the use of web proxies.
You can enable the feature as shown below.

```json
"experimentalFeatures": {
"proxy": true
},
```
17 changes: 17 additions & 0 deletions doc/admx/DesktopAppInstaller.admx
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,5 +166,22 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="EnableWindowsPackageManagerProxyCommandLineOptions" class="Machine" displayName="$(string.EnableWindowsPackageManagerProxyCommandLineOptions)" explainText="$(string.EnableWindowsPackageManagerProxyCommandLineOptionsExplanation)" key="Software\Policies\Microsoft\Windows\AppInstaller" valueName="EnableWindowsPackageManagerProxyCommandLineOptions">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="WindowsPackageManagerDefaultProxy" class="Machine" displayName="$(string.WindowsPackageManagerDefaultProxy)" explainText="$(string.WindowsPackageManagerDefaultProxyExplanation)" presentation="$(presentation.WindowsPackageManagerDefaultProxy)" key="Software\Policies\Microsoft\Windows\AppInstaller">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<elements>
<text id="WindowsPackageManagerDefaultProxy" valueName="DefaultProxy" />
</elements>
</policy>
</policies>
</policyDefinitions>
20 changes: 19 additions & 1 deletion doc/admx/en-US/DesktopAppInstaller.adml
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,7 +100,7 @@ If you disable or do not configure this setting, users will not be able to insta

If you disable this policy, users will not be able execute the Windows Package Manager CLI, and PowerShell cmdlets.

If you enable, or do not configuring this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).
If you enable, or do not configure this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).

This policy does not override the “Enable App Installer” policy.</string>
<string id="EnableWindowsPackageManagerConfiguration">Enable Windows Package Manager Configuration</string>
Expand All@@ -109,6 +109,19 @@ If you disable or do not configure this setting, users will not be able to insta
If you enable or do not configure this setting, users will be able to use the Windows Package Manager configuration feature.

If you disable this setting, users will not be able to use the Windows Package Manager configuration feature.</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptions">Enable Windows Package Manager Proxy command line options</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptionsExplanation">
This policy controls whether the Windows Package Manager usage of proxy can be configured by users through the command line.

If you enable this setting, users will be able to configure the Windows Package Manager's use of proxy through the command line.

If you disable or do not configure this setting, users will not be able to to configure the Windows Package Manager's use of proxy through the command line.</string>
<string id="WindowsPackageManagerDefaultProxy">Set Windows Package Manager Default Proxy</string>
<string id="WindowsPackageManagerDefaultProxyExplanation">This policy controls the default proxy used by the Windows Package Manager.

If you disable or do not configure this setting, no proxy will be used by default.

If you enable this setting, the specified proxy will be used by default.</string>
</stringTable>
<presentationTable>
<presentation id="SourceAutoUpdateInterval">
Expand All@@ -120,6 +133,11 @@ If you disable this setting, users will not be able to use the Windows Package M
<presentation id="AllowedSources">
<listBox refId="AllowedSources" required="false">Allowed Sources: </listBox>
</presentation>
<presentation id="WindowsPackageManagerDefaultProxy">
<textBox refId="WindowsPackageManagerDefaultProxy">
<label>Default Proxy</label>
</textBox>
</presentation>
</presentationTable>
</resources>
</policyDefinitionResources>
20 changes: 19 additions & 1 deletion schemas/JSON/settings/settings.export.schema.0.1.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,26 @@
"description": "Enable installing local manifests.",
"type": "boolean",
"default": false
},
"InstallerHashOverride": {
"description": "Enable overriding installer hash validation.",
"type": "boolean",
"default": false
},
"LocalArchiveMalwareScanOverride": {
"description": "Enable overriding malware scan for local archives.",
"type": "boolean",
"default": false
},
"ProxyCommandLineOptions": {
"description": "Enable using command line options for proxy.",
"type": "boolean",
"default": false
},
"DefaultProxy": {
"description": "Default proxy.",
"type": "string"
}
}
},
"UserSettingsFile": {
"description": "Path for the winget's user settings file.",
Expand Down
9 changes: 7 additions & 2 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,8 +266,13 @@
"type": "boolean",
"default": false
},
"configuration": {
"description": "Enable support for configuration",
"configuration03": {
"description": "Enable support for configuration schema 0.3",
"type": "boolean",
"default": false
},
"proxy": {
Comment thread
florelis marked this conversation as resolved.
"description": "Enable support for proxies",
"type": "boolean",
"default": false
}
Expand Down
21 changes: 18 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,6 +151,10 @@ namespace AppInstaller::CLI
return { type, "enable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::AdminSettingDisable:
return { type, "disable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::SettingName:
return { type, "setting"_liv };
case Execution::Args::Type::SettingValue:
return { type, "value"_liv };

// Upgrade command
case Execution::Args::Type::All:
Expand DownExpand Up@@ -233,6 +237,11 @@ namespace AppInstaller::CLI
case Execution::Args::Type::AcceptSourceAgreements:
return { type, "accept-source-agreements"_liv, ArgTypeCategory::ExtendedSource };

case Execution::Args::Type::Proxy:
return { type, "proxy"_liv, ArgTypeCategory::CopyValueToSubContext, ArgTypeExclusiveSet::Proxy };
case Execution::Args::Type::NoProxy:
return { type, "no-proxy"_liv, ArgTypeCategory::CopyFlagToSubContext, ArgTypeExclusiveSet::Proxy };

case Execution::Args::Type::ToolVersion:
return { type, "version"_liv, 'v' };

Expand DownExpand Up@@ -268,7 +277,7 @@ namespace AppInstaller::CLI
case Args::Type::MultiQuery:
return Argument{ type, Resource::String::MultiQueryArgumentDescription, ArgumentType::Positional }.SetCountLimit(128);
case Args::Type::Manifest:
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::AdminSetting::LocalManifestFiles };
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::BoolAdminSetting::LocalManifestFiles };
case Args::Type::Id:
return Argument{ type, Resource::String::IdArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help };
case Args::Type::Name:
Expand DownExpand Up@@ -308,7 +317,7 @@ namespace AppInstaller::CLI
case Args::Type::InstallLocation:
return Argument{ type, Resource::String::LocationArgumentDescription, ArgumentType::Standard };
case Args::Type::HashOverride:
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::AdminSetting::InstallerHashOverride };
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::BoolAdminSetting::InstallerHashOverride };
case Args::Type::AcceptPackageAgreements:
return Argument{ type, Resource::String::AcceptPackageAgreementsArgumentDescription, ArgumentType::Flag };
case Args::Type::NoUpgrade:
Expand All@@ -324,7 +333,7 @@ namespace AppInstaller::CLI
case Args::Type::SkipDependencies:
return Argument{ type, Resource::String::SkipDependenciesArgumentDescription, ArgumentType::Flag, false };
case Args::Type::IgnoreLocalArchiveMalwareScan:
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::AdminSetting::LocalArchiveMalwareScanOverride };
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::BoolAdminSetting::LocalArchiveMalwareScanOverride };
case Args::Type::SourceName:
return Argument{ type, Resource::String::SourceNameArgumentDescription, ArgumentType::Positional, false };
case Args::Type::SourceArg:
Expand DownExpand Up@@ -379,6 +388,10 @@ namespace AppInstaller::CLI
return Argument{ type, Resource::String::AllowRebootArgumentDescription, ArgumentType::Flag };
case Args::Type::IgnoreResumeLimit:
return Argument{ type, Resource::String::IgnoreResumeLimitArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Resume };
case Args::Type::Proxy:
return Argument{ type, Resource::String::ProxyArgumentDescription, ArgumentType::Standard, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
case Args::Type::NoProxy:
return Argument{ type, Resource::String::NoProxyArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
default:
THROW_HR(E_UNEXPECTED);
}
Expand All@@ -394,6 +407,8 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
args.emplace_back(Args::Type::DisableInteractivity, Resource::String::DisableInteractivityArgumentDescription, ArgumentType::Flag, false);
args.push_back(ForType(Args::Type::Proxy));
args.push_back(ForType(Args::Type::NoProxy));
}

std::string Argument::GetUsageString() const
Expand Down
12 changes: 8 additions & 4 deletions src/AppInstallerCLICore/Argument.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,7 @@ namespace AppInstaller::CLI
PurgePreserve = 0x4,
PinType = 0x8,
StubType = 0x10,
Proxy = 0x20,

// This must always be at the end
Max
Expand DownExpand Up@@ -211,7 +212,7 @@ namespace AppInstaller::CLI
Argument::Visibility GetVisibility() const;
Settings::ExperimentalFeature::Feature Feature() const { return m_feature; }
Settings::TogglePolicy::Policy GroupPolicy() const { return m_groupPolicy; }
Settings::AdminSetting AdminSetting() const { return m_adminSetting; }
Settings::BoolAdminSetting AdminSetting() const { return m_adminSetting; }

Argument& SetRequired(bool required) { m_required = required; return *this; }
Argument& SetCountLimit(size_t countLimit) { m_countLimit = countLimit; return *this; }
Expand All@@ -237,12 +238,15 @@ namespace AppInstaller::CLI
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, bool required, Settings::ExperimentalFeature::Feature feature) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_required(required), m_feature(feature) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::ExperimentalFeature::Feature feature, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_feature(feature), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

ArgumentCommon m_argCommon;
Resource::StringId m_desc;
bool m_required = false;
Expand All@@ -251,6 +255,6 @@ namespace AppInstaller::CLI
size_t m_countLimit = 1;
Settings::ExperimentalFeature::Feature m_feature = Settings::ExperimentalFeature::Feature::None;
Settings::TogglePolicy::Policy m_groupPolicy = Settings::TogglePolicy::Policy::None;
Settings::AdminSetting m_adminSetting = Settings::AdminSetting::Unknown;
Settings::BoolAdminSetting m_adminSetting = Settings::BoolAdminSetting::Unknown;
};
}
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Command.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -637,7 +637,7 @@ namespace AppInstaller::CLI
throw GroupPolicyException(arg.GroupPolicy());
}

if (arg.AdminSetting() != AdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
if (arg.AdminSetting() != BoolAdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
{
auto setting = Settings::AdminSettingToString(arg.AdminSetting());
AICLI_LOG(CLI, Error, << "Trying to use argument: " << arg.Name() << " disabled by admin setting " << setting);
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLICore/Commands/DownloadCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,8 +36,8 @@ namespace AppInstaller::CLI
Argument::ForType(Args::Type::CustomHeader),
Argument::ForType(Args::Type::AuthenticationMode),
Argument::ForType(Args::Type::AuthenticationAccount),
Argument::ForType(Execution::Args::Type::AcceptPackageAgreements),
Argument::ForType(Execution::Args::Type::AcceptSourceAgreements),
Argument::ForType(Args::Type::AcceptPackageAgreements),
Argument::ForType(Args::Type::AcceptSourceAgreements),
};
}

Expand Down
10 changes: 9 additions & 1 deletion src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,13 +124,21 @@ namespace AppInstaller::CLI
Execution::TableOutput<2> adminSettingsTable{ context.Reporter, { Resource::String::AdminSettingHeader, Resource::String::StateHeader } };

// Output the admin settings.
for (const auto& setting : Settings::GetAllAdminSettings())
for (const auto& setting : Settings::GetAllBoolAdminSettings())
{
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
Resource::LocString{ IsAdminSettingEnabled(setting) ? Resource::String::StateEnabled : Resource::String::StateDisabled }
});
}
for (const auto& setting : Settings::GetAllStringAdminSettings())
{
auto settingValue = GetAdminSetting(setting);
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
settingValue ? Utility::LocIndString{ settingValue.value() } : Resource::LocString{ Resource::String::StateDisabled }
});
}
adminSettingsTable.Complete();
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Add support for proxies #190 by florelis · Pull Request #4203 · microsoft/winget-cli · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2f4391b
Add admin setting for enabling proxy
florelis Feb 15, 2024
b7f8153
Add proxy argument
florelis Feb 16, 2024
b2d9f31
Add group policy
florelis Feb 17, 2024
d729041
Fix bad name copy
florelis Feb 17, 2024
426a5f3
Add policy for default proxy
florelis Feb 21, 2024
f795ce2
Add proxy to context
florelis Feb 21, 2024
4d73e74
Add experimental feature
florelis Feb 22, 2024
59b0a5f
Pass proxy info to some places it is needed
florelis Feb 23, 2024
d002528
Add proxy info to sources
florelis Feb 23, 2024
7caaa86
Add admin setting for default proxy
florelis Feb 24, 2024
1a588b0
Use admin setting for proxy
florelis Feb 24, 2024
682e07e
Add to info, export
florelis Feb 24, 2024
2f843c0
Add proxy to settings schema experimental features
florelis Feb 26, 2024
e984f7f
Typo
florelis Feb 26, 2024
f5fa5f1
Merge branch 'master' into proxy
florelis Feb 26, 2024
284a1ce
Fix id
florelis Feb 26, 2024
17264b7
missing ;
florelis Feb 26, 2024
8a11d7c
Use existing httpclienthelper
florelis Feb 27, 2024
3172238
Fix string id
florelis Feb 27, 2024
2a2def3
Merge branch 'master' into proxy
florelis Feb 27, 2024
2e065e6
Make proxy settings global
florelis Feb 29, 2024
48872d5
Make proxy arguments common
florelis Feb 29, 2024
87dba88
Update doc/admx/en-US/DesktopAppInstaller.adml
florelis Mar 11, 2024
d20d685
Fix set default proxy
florelis Mar 11, 2024
0d92842
Move setting proxy to HttpClientHelper constructor
florelis Mar 11, 2024
84fb0da
Add to settings.md
florelis Mar 11, 2024
193d2eb
Update settings schema
florelis Mar 11, 2024
25facf1
Fix arg name
florelis Mar 11, 2024
e0fdcf7
Reset bool admin settings
florelis Mar 11, 2024
3d8f87a
LocIndString
florelis Mar 11, 2024
48d2ab5
Update src/AppInstallerCLICore/Commands/SettingsCommand.cpp
florelis Mar 14, 2024
97e9415
Update src/AppInstallerCLICore/Workflows/SettingsFlow.cpp
florelis Mar 14, 2024
ce47cf5
PR suggestion
florelis Mar 14, 2024
fb18813
Missing )
florelis Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -312,3 +312,14 @@ You can enable the feature as shown below.
"configuration03": true
},
```

### proxy

This feature enables the use of web proxies.
You can enable the feature as shown below.

```json
"experimentalFeatures": {
"proxy": true
},
```
17 changes: 17 additions & 0 deletions doc/admx/DesktopAppInstaller.admx
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,5 +166,22 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="EnableWindowsPackageManagerProxyCommandLineOptions" class="Machine" displayName="$(string.EnableWindowsPackageManagerProxyCommandLineOptions)" explainText="$(string.EnableWindowsPackageManagerProxyCommandLineOptionsExplanation)" key="Software\Policies\Microsoft\Windows\AppInstaller" valueName="EnableWindowsPackageManagerProxyCommandLineOptions">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="WindowsPackageManagerDefaultProxy" class="Machine" displayName="$(string.WindowsPackageManagerDefaultProxy)" explainText="$(string.WindowsPackageManagerDefaultProxyExplanation)" presentation="$(presentation.WindowsPackageManagerDefaultProxy)" key="Software\Policies\Microsoft\Windows\AppInstaller">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<elements>
<text id="WindowsPackageManagerDefaultProxy" valueName="DefaultProxy" />
</elements>
</policy>
</policies>
</policyDefinitions>
20 changes: 19 additions & 1 deletion doc/admx/en-US/DesktopAppInstaller.adml
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,7 +100,7 @@ If you disable or do not configure this setting, users will not be able to insta

If you disable this policy, users will not be able execute the Windows Package Manager CLI, and PowerShell cmdlets.

If you enable, or do not configuring this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).
If you enable, or do not configure this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).

This policy does not override the “Enable App Installer” policy.</string>
<string id="EnableWindowsPackageManagerConfiguration">Enable Windows Package Manager Configuration</string>
Expand All@@ -109,6 +109,19 @@ If you disable or do not configure this setting, users will not be able to insta
If you enable or do not configure this setting, users will be able to use the Windows Package Manager configuration feature.

If you disable this setting, users will not be able to use the Windows Package Manager configuration feature.</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptions">Enable Windows Package Manager Proxy command line options</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptionsExplanation">
This policy controls whether the Windows Package Manager usage of proxy can be configured by users through the command line.

If you enable this setting, users will be able to configure the Windows Package Manager's use of proxy through the command line.

If you disable or do not configure this setting, users will not be able to to configure the Windows Package Manager's use of proxy through the command line.</string>
<string id="WindowsPackageManagerDefaultProxy">Set Windows Package Manager Default Proxy</string>
<string id="WindowsPackageManagerDefaultProxyExplanation">This policy controls the default proxy used by the Windows Package Manager.

If you disable or do not configure this setting, no proxy will be used by default.

If you enable this setting, the specified proxy will be used by default.</string>
</stringTable>
<presentationTable>
<presentation id="SourceAutoUpdateInterval">
Expand All@@ -120,6 +133,11 @@ If you disable this setting, users will not be able to use the Windows Package M
<presentation id="AllowedSources">
<listBox refId="AllowedSources" required="false">Allowed Sources: </listBox>
</presentation>
<presentation id="WindowsPackageManagerDefaultProxy">
<textBox refId="WindowsPackageManagerDefaultProxy">
<label>Default Proxy</label>
</textBox>
</presentation>
</presentationTable>
</resources>
</policyDefinitionResources>
20 changes: 19 additions & 1 deletion schemas/JSON/settings/settings.export.schema.0.1.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,26 @@
"description": "Enable installing local manifests.",
"type": "boolean",
"default": false
},
"InstallerHashOverride": {
"description": "Enable overriding installer hash validation.",
"type": "boolean",
"default": false
},
"LocalArchiveMalwareScanOverride": {
"description": "Enable overriding malware scan for local archives.",
"type": "boolean",
"default": false
},
"ProxyCommandLineOptions": {
"description": "Enable using command line options for proxy.",
"type": "boolean",
"default": false
},
"DefaultProxy": {
"description": "Default proxy.",
"type": "string"
}
}
},
"UserSettingsFile": {
"description": "Path for the winget's user settings file.",
Expand Down
9 changes: 7 additions & 2 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,8 +266,13 @@
"type": "boolean",
"default": false
},
"configuration": {
"description": "Enable support for configuration",
"configuration03": {
"description": "Enable support for configuration schema 0.3",
"type": "boolean",
"default": false
},
"proxy": {
Comment thread
florelis marked this conversation as resolved.
"description": "Enable support for proxies",
"type": "boolean",
"default": false
}
Expand Down
21 changes: 18 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,6 +151,10 @@ namespace AppInstaller::CLI
return { type, "enable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::AdminSettingDisable:
return { type, "disable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::SettingName:
return { type, "setting"_liv };
case Execution::Args::Type::SettingValue:
return { type, "value"_liv };

// Upgrade command
case Execution::Args::Type::All:
Expand DownExpand Up@@ -233,6 +237,11 @@ namespace AppInstaller::CLI
case Execution::Args::Type::AcceptSourceAgreements:
return { type, "accept-source-agreements"_liv, ArgTypeCategory::ExtendedSource };

case Execution::Args::Type::Proxy:
return { type, "proxy"_liv, ArgTypeCategory::CopyValueToSubContext, ArgTypeExclusiveSet::Proxy };
case Execution::Args::Type::NoProxy:
return { type, "no-proxy"_liv, ArgTypeCategory::CopyFlagToSubContext, ArgTypeExclusiveSet::Proxy };

case Execution::Args::Type::ToolVersion:
return { type, "version"_liv, 'v' };

Expand DownExpand Up@@ -268,7 +277,7 @@ namespace AppInstaller::CLI
case Args::Type::MultiQuery:
return Argument{ type, Resource::String::MultiQueryArgumentDescription, ArgumentType::Positional }.SetCountLimit(128);
case Args::Type::Manifest:
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::AdminSetting::LocalManifestFiles };
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::BoolAdminSetting::LocalManifestFiles };
case Args::Type::Id:
return Argument{ type, Resource::String::IdArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help };
case Args::Type::Name:
Expand DownExpand Up@@ -308,7 +317,7 @@ namespace AppInstaller::CLI
case Args::Type::InstallLocation:
return Argument{ type, Resource::String::LocationArgumentDescription, ArgumentType::Standard };
case Args::Type::HashOverride:
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::AdminSetting::InstallerHashOverride };
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::BoolAdminSetting::InstallerHashOverride };
case Args::Type::AcceptPackageAgreements:
return Argument{ type, Resource::String::AcceptPackageAgreementsArgumentDescription, ArgumentType::Flag };
case Args::Type::NoUpgrade:
Expand All@@ -324,7 +333,7 @@ namespace AppInstaller::CLI
case Args::Type::SkipDependencies:
return Argument{ type, Resource::String::SkipDependenciesArgumentDescription, ArgumentType::Flag, false };
case Args::Type::IgnoreLocalArchiveMalwareScan:
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::AdminSetting::LocalArchiveMalwareScanOverride };
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::BoolAdminSetting::LocalArchiveMalwareScanOverride };
case Args::Type::SourceName:
return Argument{ type, Resource::String::SourceNameArgumentDescription, ArgumentType::Positional, false };
case Args::Type::SourceArg:
Expand DownExpand Up@@ -379,6 +388,10 @@ namespace AppInstaller::CLI
return Argument{ type, Resource::String::AllowRebootArgumentDescription, ArgumentType::Flag };
case Args::Type::IgnoreResumeLimit:
return Argument{ type, Resource::String::IgnoreResumeLimitArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Resume };
case Args::Type::Proxy:
return Argument{ type, Resource::String::ProxyArgumentDescription, ArgumentType::Standard, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
case Args::Type::NoProxy:
return Argument{ type, Resource::String::NoProxyArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
default:
THROW_HR(E_UNEXPECTED);
}
Expand All@@ -394,6 +407,8 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
args.emplace_back(Args::Type::DisableInteractivity, Resource::String::DisableInteractivityArgumentDescription, ArgumentType::Flag, false);
args.push_back(ForType(Args::Type::Proxy));
args.push_back(ForType(Args::Type::NoProxy));
}

std::string Argument::GetUsageString() const
Expand Down
12 changes: 8 additions & 4 deletions src/AppInstallerCLICore/Argument.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,7 @@ namespace AppInstaller::CLI
PurgePreserve = 0x4,
PinType = 0x8,
StubType = 0x10,
Proxy = 0x20,

// This must always be at the end
Max
Expand DownExpand Up@@ -211,7 +212,7 @@ namespace AppInstaller::CLI
Argument::Visibility GetVisibility() const;
Settings::ExperimentalFeature::Feature Feature() const { return m_feature; }
Settings::TogglePolicy::Policy GroupPolicy() const { return m_groupPolicy; }
Settings::AdminSetting AdminSetting() const { return m_adminSetting; }
Settings::BoolAdminSetting AdminSetting() const { return m_adminSetting; }

Argument& SetRequired(bool required) { m_required = required; return *this; }
Argument& SetCountLimit(size_t countLimit) { m_countLimit = countLimit; return *this; }
Expand All@@ -237,12 +238,15 @@ namespace AppInstaller::CLI
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, bool required, Settings::ExperimentalFeature::Feature feature) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_required(required), m_feature(feature) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::ExperimentalFeature::Feature feature, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_feature(feature), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

ArgumentCommon m_argCommon;
Resource::StringId m_desc;
bool m_required = false;
Expand All@@ -251,6 +255,6 @@ namespace AppInstaller::CLI
size_t m_countLimit = 1;
Settings::ExperimentalFeature::Feature m_feature = Settings::ExperimentalFeature::Feature::None;
Settings::TogglePolicy::Policy m_groupPolicy = Settings::TogglePolicy::Policy::None;
Settings::AdminSetting m_adminSetting = Settings::AdminSetting::Unknown;
Settings::BoolAdminSetting m_adminSetting = Settings::BoolAdminSetting::Unknown;
};
}
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Command.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -637,7 +637,7 @@ namespace AppInstaller::CLI
throw GroupPolicyException(arg.GroupPolicy());
}

if (arg.AdminSetting() != AdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
if (arg.AdminSetting() != BoolAdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
{
auto setting = Settings::AdminSettingToString(arg.AdminSetting());
AICLI_LOG(CLI, Error, << "Trying to use argument: " << arg.Name() << " disabled by admin setting " << setting);
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLICore/Commands/DownloadCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,8 +36,8 @@ namespace AppInstaller::CLI
Argument::ForType(Args::Type::CustomHeader),
Argument::ForType(Args::Type::AuthenticationMode),
Argument::ForType(Args::Type::AuthenticationAccount),
Argument::ForType(Execution::Args::Type::AcceptPackageAgreements),
Argument::ForType(Execution::Args::Type::AcceptSourceAgreements),
Argument::ForType(Args::Type::AcceptPackageAgreements),
Argument::ForType(Args::Type::AcceptSourceAgreements),
};
}

Expand Down
10 changes: 9 additions & 1 deletion src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,13 +124,21 @@ namespace AppInstaller::CLI
Execution::TableOutput<2> adminSettingsTable{ context.Reporter, { Resource::String::AdminSettingHeader, Resource::String::StateHeader } };

// Output the admin settings.
for (const auto& setting : Settings::GetAllAdminSettings())
for (const auto& setting : Settings::GetAllBoolAdminSettings())
{
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
Resource::LocString{ IsAdminSettingEnabled(setting) ? Resource::String::StateEnabled : Resource::String::StateDisabled }
});
}
for (const auto& setting : Settings::GetAllStringAdminSettings())
{
auto settingValue = GetAdminSetting(setting);
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
settingValue ? Utility::LocIndString{ settingValue.value() } : Resource::LocString{ Resource::String::StateDisabled }
});
}
adminSettingsTable.Complete();
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add support for proxies #190 by florelis · Pull Request #4203 · microsoft/winget-cli · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2f4391b
Add admin setting for enabling proxy
florelis Feb 15, 2024
b7f8153
Add proxy argument
florelis Feb 16, 2024
b2d9f31
Add group policy
florelis Feb 17, 2024
d729041
Fix bad name copy
florelis Feb 17, 2024
426a5f3
Add policy for default proxy
florelis Feb 21, 2024
f795ce2
Add proxy to context
florelis Feb 21, 2024
4d73e74
Add experimental feature
florelis Feb 22, 2024
59b0a5f
Pass proxy info to some places it is needed
florelis Feb 23, 2024
d002528
Add proxy info to sources
florelis Feb 23, 2024
7caaa86
Add admin setting for default proxy
florelis Feb 24, 2024
1a588b0
Use admin setting for proxy
florelis Feb 24, 2024
682e07e
Add to info, export
florelis Feb 24, 2024
2f843c0
Add proxy to settings schema experimental features
florelis Feb 26, 2024
e984f7f
Typo
florelis Feb 26, 2024
f5fa5f1
Merge branch 'master' into proxy
florelis Feb 26, 2024
284a1ce
Fix id
florelis Feb 26, 2024
17264b7
missing ;
florelis Feb 26, 2024
8a11d7c
Use existing httpclienthelper
florelis Feb 27, 2024
3172238
Fix string id
florelis Feb 27, 2024
2a2def3
Merge branch 'master' into proxy
florelis Feb 27, 2024
2e065e6
Make proxy settings global
florelis Feb 29, 2024
48872d5
Make proxy arguments common
florelis Feb 29, 2024
87dba88
Update doc/admx/en-US/DesktopAppInstaller.adml
florelis Mar 11, 2024
d20d685
Fix set default proxy
florelis Mar 11, 2024
0d92842
Move setting proxy to HttpClientHelper constructor
florelis Mar 11, 2024
84fb0da
Add to settings.md
florelis Mar 11, 2024
193d2eb
Update settings schema
florelis Mar 11, 2024
25facf1
Fix arg name
florelis Mar 11, 2024
e0fdcf7
Reset bool admin settings
florelis Mar 11, 2024
3d8f87a
LocIndString
florelis Mar 11, 2024
48d2ab5
Update src/AppInstallerCLICore/Commands/SettingsCommand.cpp
florelis Mar 14, 2024
97e9415
Update src/AppInstallerCLICore/Workflows/SettingsFlow.cpp
florelis Mar 14, 2024
ce47cf5
PR suggestion
florelis Mar 14, 2024
fb18813
Missing )
florelis Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -312,3 +312,14 @@ You can enable the feature as shown below.
"configuration03": true
},
```

### proxy

This feature enables the use of web proxies.
You can enable the feature as shown below.

```json
"experimentalFeatures": {
"proxy": true
},
```
17 changes: 17 additions & 0 deletions doc/admx/DesktopAppInstaller.admx
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,5 +166,22 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="EnableWindowsPackageManagerProxyCommandLineOptions" class="Machine" displayName="$(string.EnableWindowsPackageManagerProxyCommandLineOptions)" explainText="$(string.EnableWindowsPackageManagerProxyCommandLineOptionsExplanation)" key="Software\Policies\Microsoft\Windows\AppInstaller" valueName="EnableWindowsPackageManagerProxyCommandLineOptions">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="WindowsPackageManagerDefaultProxy" class="Machine" displayName="$(string.WindowsPackageManagerDefaultProxy)" explainText="$(string.WindowsPackageManagerDefaultProxyExplanation)" presentation="$(presentation.WindowsPackageManagerDefaultProxy)" key="Software\Policies\Microsoft\Windows\AppInstaller">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<elements>
<text id="WindowsPackageManagerDefaultProxy" valueName="DefaultProxy" />
</elements>
</policy>
</policies>
</policyDefinitions>
20 changes: 19 additions & 1 deletion doc/admx/en-US/DesktopAppInstaller.adml
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,7 +100,7 @@ If you disable or do not configure this setting, users will not be able to insta

If you disable this policy, users will not be able execute the Windows Package Manager CLI, and PowerShell cmdlets.

If you enable, or do not configuring this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).
If you enable, or do not configure this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).

This policy does not override the “Enable App Installer” policy.</string>
<string id="EnableWindowsPackageManagerConfiguration">Enable Windows Package Manager Configuration</string>
Expand All@@ -109,6 +109,19 @@ If you disable or do not configure this setting, users will not be able to insta
If you enable or do not configure this setting, users will be able to use the Windows Package Manager configuration feature.

If you disable this setting, users will not be able to use the Windows Package Manager configuration feature.</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptions">Enable Windows Package Manager Proxy command line options</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptionsExplanation">
This policy controls whether the Windows Package Manager usage of proxy can be configured by users through the command line.

If you enable this setting, users will be able to configure the Windows Package Manager's use of proxy through the command line.

If you disable or do not configure this setting, users will not be able to to configure the Windows Package Manager's use of proxy through the command line.</string>
<string id="WindowsPackageManagerDefaultProxy">Set Windows Package Manager Default Proxy</string>
<string id="WindowsPackageManagerDefaultProxyExplanation">This policy controls the default proxy used by the Windows Package Manager.

If you disable or do not configure this setting, no proxy will be used by default.

If you enable this setting, the specified proxy will be used by default.</string>
</stringTable>
<presentationTable>
<presentation id="SourceAutoUpdateInterval">
Expand All@@ -120,6 +133,11 @@ If you disable this setting, users will not be able to use the Windows Package M
<presentation id="AllowedSources">
<listBox refId="AllowedSources" required="false">Allowed Sources: </listBox>
</presentation>
<presentation id="WindowsPackageManagerDefaultProxy">
<textBox refId="WindowsPackageManagerDefaultProxy">
<label>Default Proxy</label>
</textBox>
</presentation>
</presentationTable>
</resources>
</policyDefinitionResources>
20 changes: 19 additions & 1 deletion schemas/JSON/settings/settings.export.schema.0.1.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,26 @@
"description": "Enable installing local manifests.",
"type": "boolean",
"default": false
},
"InstallerHashOverride": {
"description": "Enable overriding installer hash validation.",
"type": "boolean",
"default": false
},
"LocalArchiveMalwareScanOverride": {
"description": "Enable overriding malware scan for local archives.",
"type": "boolean",
"default": false
},
"ProxyCommandLineOptions": {
"description": "Enable using command line options for proxy.",
"type": "boolean",
"default": false
},
"DefaultProxy": {
"description": "Default proxy.",
"type": "string"
}
}
},
"UserSettingsFile": {
"description": "Path for the winget's user settings file.",
Expand Down
9 changes: 7 additions & 2 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,8 +266,13 @@
"type": "boolean",
"default": false
},
"configuration": {
"description": "Enable support for configuration",
"configuration03": {
"description": "Enable support for configuration schema 0.3",
"type": "boolean",
"default": false
},
"proxy": {
Comment thread
florelis marked this conversation as resolved.
"description": "Enable support for proxies",
"type": "boolean",
"default": false
}
Expand Down
21 changes: 18 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,6 +151,10 @@ namespace AppInstaller::CLI
return { type, "enable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::AdminSettingDisable:
return { type, "disable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::SettingName:
return { type, "setting"_liv };
case Execution::Args::Type::SettingValue:
return { type, "value"_liv };

// Upgrade command
case Execution::Args::Type::All:
Expand DownExpand Up@@ -233,6 +237,11 @@ namespace AppInstaller::CLI
case Execution::Args::Type::AcceptSourceAgreements:
return { type, "accept-source-agreements"_liv, ArgTypeCategory::ExtendedSource };

case Execution::Args::Type::Proxy:
return { type, "proxy"_liv, ArgTypeCategory::CopyValueToSubContext, ArgTypeExclusiveSet::Proxy };
case Execution::Args::Type::NoProxy:
return { type, "no-proxy"_liv, ArgTypeCategory::CopyFlagToSubContext, ArgTypeExclusiveSet::Proxy };

case Execution::Args::Type::ToolVersion:
return { type, "version"_liv, 'v' };

Expand DownExpand Up@@ -268,7 +277,7 @@ namespace AppInstaller::CLI
case Args::Type::MultiQuery:
return Argument{ type, Resource::String::MultiQueryArgumentDescription, ArgumentType::Positional }.SetCountLimit(128);
case Args::Type::Manifest:
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::AdminSetting::LocalManifestFiles };
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::BoolAdminSetting::LocalManifestFiles };
case Args::Type::Id:
return Argument{ type, Resource::String::IdArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help };
case Args::Type::Name:
Expand DownExpand Up@@ -308,7 +317,7 @@ namespace AppInstaller::CLI
case Args::Type::InstallLocation:
return Argument{ type, Resource::String::LocationArgumentDescription, ArgumentType::Standard };
case Args::Type::HashOverride:
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::AdminSetting::InstallerHashOverride };
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::BoolAdminSetting::InstallerHashOverride };
case Args::Type::AcceptPackageAgreements:
return Argument{ type, Resource::String::AcceptPackageAgreementsArgumentDescription, ArgumentType::Flag };
case Args::Type::NoUpgrade:
Expand All@@ -324,7 +333,7 @@ namespace AppInstaller::CLI
case Args::Type::SkipDependencies:
return Argument{ type, Resource::String::SkipDependenciesArgumentDescription, ArgumentType::Flag, false };
case Args::Type::IgnoreLocalArchiveMalwareScan:
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::AdminSetting::LocalArchiveMalwareScanOverride };
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::BoolAdminSetting::LocalArchiveMalwareScanOverride };
case Args::Type::SourceName:
return Argument{ type, Resource::String::SourceNameArgumentDescription, ArgumentType::Positional, false };
case Args::Type::SourceArg:
Expand DownExpand Up@@ -379,6 +388,10 @@ namespace AppInstaller::CLI
return Argument{ type, Resource::String::AllowRebootArgumentDescription, ArgumentType::Flag };
case Args::Type::IgnoreResumeLimit:
return Argument{ type, Resource::String::IgnoreResumeLimitArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Resume };
case Args::Type::Proxy:
return Argument{ type, Resource::String::ProxyArgumentDescription, ArgumentType::Standard, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
case Args::Type::NoProxy:
return Argument{ type, Resource::String::NoProxyArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
default:
THROW_HR(E_UNEXPECTED);
}
Expand All@@ -394,6 +407,8 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
args.emplace_back(Args::Type::DisableInteractivity, Resource::String::DisableInteractivityArgumentDescription, ArgumentType::Flag, false);
args.push_back(ForType(Args::Type::Proxy));
args.push_back(ForType(Args::Type::NoProxy));
}

std::string Argument::GetUsageString() const
Expand Down
12 changes: 8 additions & 4 deletions src/AppInstallerCLICore/Argument.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,7 @@ namespace AppInstaller::CLI
PurgePreserve = 0x4,
PinType = 0x8,
StubType = 0x10,
Proxy = 0x20,

// This must always be at the end
Max
Expand DownExpand Up@@ -211,7 +212,7 @@ namespace AppInstaller::CLI
Argument::Visibility GetVisibility() const;
Settings::ExperimentalFeature::Feature Feature() const { return m_feature; }
Settings::TogglePolicy::Policy GroupPolicy() const { return m_groupPolicy; }
Settings::AdminSetting AdminSetting() const { return m_adminSetting; }
Settings::BoolAdminSetting AdminSetting() const { return m_adminSetting; }

Argument& SetRequired(bool required) { m_required = required; return *this; }
Argument& SetCountLimit(size_t countLimit) { m_countLimit = countLimit; return *this; }
Expand All@@ -237,12 +238,15 @@ namespace AppInstaller::CLI
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, bool required, Settings::ExperimentalFeature::Feature feature) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_required(required), m_feature(feature) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::ExperimentalFeature::Feature feature, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_feature(feature), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

ArgumentCommon m_argCommon;
Resource::StringId m_desc;
bool m_required = false;
Expand All@@ -251,6 +255,6 @@ namespace AppInstaller::CLI
size_t m_countLimit = 1;
Settings::ExperimentalFeature::Feature m_feature = Settings::ExperimentalFeature::Feature::None;
Settings::TogglePolicy::Policy m_groupPolicy = Settings::TogglePolicy::Policy::None;
Settings::AdminSetting m_adminSetting = Settings::AdminSetting::Unknown;
Settings::BoolAdminSetting m_adminSetting = Settings::BoolAdminSetting::Unknown;
};
}
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Command.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -637,7 +637,7 @@ namespace AppInstaller::CLI
throw GroupPolicyException(arg.GroupPolicy());
}

if (arg.AdminSetting() != AdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
if (arg.AdminSetting() != BoolAdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
{
auto setting = Settings::AdminSettingToString(arg.AdminSetting());
AICLI_LOG(CLI, Error, << "Trying to use argument: " << arg.Name() << " disabled by admin setting " << setting);
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLICore/Commands/DownloadCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,8 +36,8 @@ namespace AppInstaller::CLI
Argument::ForType(Args::Type::CustomHeader),
Argument::ForType(Args::Type::AuthenticationMode),
Argument::ForType(Args::Type::AuthenticationAccount),
Argument::ForType(Execution::Args::Type::AcceptPackageAgreements),
Argument::ForType(Execution::Args::Type::AcceptSourceAgreements),
Argument::ForType(Args::Type::AcceptPackageAgreements),
Argument::ForType(Args::Type::AcceptSourceAgreements),
};
}

Expand Down
10 changes: 9 additions & 1 deletion src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,13 +124,21 @@ namespace AppInstaller::CLI
Execution::TableOutput<2> adminSettingsTable{ context.Reporter, { Resource::String::AdminSettingHeader, Resource::String::StateHeader } };

// Output the admin settings.
for (const auto& setting : Settings::GetAllAdminSettings())
for (const auto& setting : Settings::GetAllBoolAdminSettings())
{
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
Resource::LocString{ IsAdminSettingEnabled(setting) ? Resource::String::StateEnabled : Resource::String::StateDisabled }
});
}
for (const auto& setting : Settings::GetAllStringAdminSettings())
{
auto settingValue = GetAdminSetting(setting);
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
settingValue ? Utility::LocIndString{ settingValue.value() } : Resource::LocString{ Resource::String::StateDisabled }
});
}
adminSettingsTable.Complete();
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add support for proxies #190 by florelis · Pull Request #4203 · microsoft/winget-cli · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2f4391b
Add admin setting for enabling proxy
florelis Feb 15, 2024
b7f8153
Add proxy argument
florelis Feb 16, 2024
b2d9f31
Add group policy
florelis Feb 17, 2024
d729041
Fix bad name copy
florelis Feb 17, 2024
426a5f3
Add policy for default proxy
florelis Feb 21, 2024
f795ce2
Add proxy to context
florelis Feb 21, 2024
4d73e74
Add experimental feature
florelis Feb 22, 2024
59b0a5f
Pass proxy info to some places it is needed
florelis Feb 23, 2024
d002528
Add proxy info to sources
florelis Feb 23, 2024
7caaa86
Add admin setting for default proxy
florelis Feb 24, 2024
1a588b0
Use admin setting for proxy
florelis Feb 24, 2024
682e07e
Add to info, export
florelis Feb 24, 2024
2f843c0
Add proxy to settings schema experimental features
florelis Feb 26, 2024
e984f7f
Typo
florelis Feb 26, 2024
f5fa5f1
Merge branch 'master' into proxy
florelis Feb 26, 2024
284a1ce
Fix id
florelis Feb 26, 2024
17264b7
missing ;
florelis Feb 26, 2024
8a11d7c
Use existing httpclienthelper
florelis Feb 27, 2024
3172238
Fix string id
florelis Feb 27, 2024
2a2def3
Merge branch 'master' into proxy
florelis Feb 27, 2024
2e065e6
Make proxy settings global
florelis Feb 29, 2024
48872d5
Make proxy arguments common
florelis Feb 29, 2024
87dba88
Update doc/admx/en-US/DesktopAppInstaller.adml
florelis Mar 11, 2024
d20d685
Fix set default proxy
florelis Mar 11, 2024
0d92842
Move setting proxy to HttpClientHelper constructor
florelis Mar 11, 2024
84fb0da
Add to settings.md
florelis Mar 11, 2024
193d2eb
Update settings schema
florelis Mar 11, 2024
25facf1
Fix arg name
florelis Mar 11, 2024
e0fdcf7
Reset bool admin settings
florelis Mar 11, 2024
3d8f87a
LocIndString
florelis Mar 11, 2024
48d2ab5
Update src/AppInstallerCLICore/Commands/SettingsCommand.cpp
florelis Mar 14, 2024
97e9415
Update src/AppInstallerCLICore/Workflows/SettingsFlow.cpp
florelis Mar 14, 2024
ce47cf5
PR suggestion
florelis Mar 14, 2024
fb18813
Missing )
florelis Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -312,3 +312,14 @@ You can enable the feature as shown below.
"configuration03": true
},
```

### proxy

This feature enables the use of web proxies.
You can enable the feature as shown below.

```json
"experimentalFeatures": {
"proxy": true
},
```
17 changes: 17 additions & 0 deletions doc/admx/DesktopAppInstaller.admx
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,5 +166,22 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="EnableWindowsPackageManagerProxyCommandLineOptions" class="Machine" displayName="$(string.EnableWindowsPackageManagerProxyCommandLineOptions)" explainText="$(string.EnableWindowsPackageManagerProxyCommandLineOptionsExplanation)" key="Software\Policies\Microsoft\Windows\AppInstaller" valueName="EnableWindowsPackageManagerProxyCommandLineOptions">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="WindowsPackageManagerDefaultProxy" class="Machine" displayName="$(string.WindowsPackageManagerDefaultProxy)" explainText="$(string.WindowsPackageManagerDefaultProxyExplanation)" presentation="$(presentation.WindowsPackageManagerDefaultProxy)" key="Software\Policies\Microsoft\Windows\AppInstaller">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<elements>
<text id="WindowsPackageManagerDefaultProxy" valueName="DefaultProxy" />
</elements>
</policy>
</policies>
</policyDefinitions>
20 changes: 19 additions & 1 deletion doc/admx/en-US/DesktopAppInstaller.adml
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,7 +100,7 @@ If you disable or do not configure this setting, users will not be able to insta

If you disable this policy, users will not be able execute the Windows Package Manager CLI, and PowerShell cmdlets.

If you enable, or do not configuring this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).
If you enable, or do not configure this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).

This policy does not override the “Enable App Installer” policy.</string>
<string id="EnableWindowsPackageManagerConfiguration">Enable Windows Package Manager Configuration</string>
Expand All@@ -109,6 +109,19 @@ If you disable or do not configure this setting, users will not be able to insta
If you enable or do not configure this setting, users will be able to use the Windows Package Manager configuration feature.

If you disable this setting, users will not be able to use the Windows Package Manager configuration feature.</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptions">Enable Windows Package Manager Proxy command line options</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptionsExplanation">
This policy controls whether the Windows Package Manager usage of proxy can be configured by users through the command line.

If you enable this setting, users will be able to configure the Windows Package Manager's use of proxy through the command line.

If you disable or do not configure this setting, users will not be able to to configure the Windows Package Manager's use of proxy through the command line.</string>
<string id="WindowsPackageManagerDefaultProxy">Set Windows Package Manager Default Proxy</string>
<string id="WindowsPackageManagerDefaultProxyExplanation">This policy controls the default proxy used by the Windows Package Manager.

If you disable or do not configure this setting, no proxy will be used by default.

If you enable this setting, the specified proxy will be used by default.</string>
</stringTable>
<presentationTable>
<presentation id="SourceAutoUpdateInterval">
Expand All@@ -120,6 +133,11 @@ If you disable this setting, users will not be able to use the Windows Package M
<presentation id="AllowedSources">
<listBox refId="AllowedSources" required="false">Allowed Sources: </listBox>
</presentation>
<presentation id="WindowsPackageManagerDefaultProxy">
<textBox refId="WindowsPackageManagerDefaultProxy">
<label>Default Proxy</label>
</textBox>
</presentation>
</presentationTable>
</resources>
</policyDefinitionResources>
20 changes: 19 additions & 1 deletion schemas/JSON/settings/settings.export.schema.0.1.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,26 @@
"description": "Enable installing local manifests.",
"type": "boolean",
"default": false
},
"InstallerHashOverride": {
"description": "Enable overriding installer hash validation.",
"type": "boolean",
"default": false
},
"LocalArchiveMalwareScanOverride": {
"description": "Enable overriding malware scan for local archives.",
"type": "boolean",
"default": false
},
"ProxyCommandLineOptions": {
"description": "Enable using command line options for proxy.",
"type": "boolean",
"default": false
},
"DefaultProxy": {
"description": "Default proxy.",
"type": "string"
}
}
},
"UserSettingsFile": {
"description": "Path for the winget's user settings file.",
Expand Down
9 changes: 7 additions & 2 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,8 +266,13 @@
"type": "boolean",
"default": false
},
"configuration": {
"description": "Enable support for configuration",
"configuration03": {
"description": "Enable support for configuration schema 0.3",
"type": "boolean",
"default": false
},
"proxy": {
Comment thread
florelis marked this conversation as resolved.
"description": "Enable support for proxies",
"type": "boolean",
"default": false
}
Expand Down
21 changes: 18 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,6 +151,10 @@ namespace AppInstaller::CLI
return { type, "enable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::AdminSettingDisable:
return { type, "disable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::SettingName:
return { type, "setting"_liv };
case Execution::Args::Type::SettingValue:
return { type, "value"_liv };

// Upgrade command
case Execution::Args::Type::All:
Expand DownExpand Up@@ -233,6 +237,11 @@ namespace AppInstaller::CLI
case Execution::Args::Type::AcceptSourceAgreements:
return { type, "accept-source-agreements"_liv, ArgTypeCategory::ExtendedSource };

case Execution::Args::Type::Proxy:
return { type, "proxy"_liv, ArgTypeCategory::CopyValueToSubContext, ArgTypeExclusiveSet::Proxy };
case Execution::Args::Type::NoProxy:
return { type, "no-proxy"_liv, ArgTypeCategory::CopyFlagToSubContext, ArgTypeExclusiveSet::Proxy };

case Execution::Args::Type::ToolVersion:
return { type, "version"_liv, 'v' };

Expand DownExpand Up@@ -268,7 +277,7 @@ namespace AppInstaller::CLI
case Args::Type::MultiQuery:
return Argument{ type, Resource::String::MultiQueryArgumentDescription, ArgumentType::Positional }.SetCountLimit(128);
case Args::Type::Manifest:
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::AdminSetting::LocalManifestFiles };
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::BoolAdminSetting::LocalManifestFiles };
case Args::Type::Id:
return Argument{ type, Resource::String::IdArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help };
case Args::Type::Name:
Expand DownExpand Up@@ -308,7 +317,7 @@ namespace AppInstaller::CLI
case Args::Type::InstallLocation:
return Argument{ type, Resource::String::LocationArgumentDescription, ArgumentType::Standard };
case Args::Type::HashOverride:
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::AdminSetting::InstallerHashOverride };
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::BoolAdminSetting::InstallerHashOverride };
case Args::Type::AcceptPackageAgreements:
return Argument{ type, Resource::String::AcceptPackageAgreementsArgumentDescription, ArgumentType::Flag };
case Args::Type::NoUpgrade:
Expand All@@ -324,7 +333,7 @@ namespace AppInstaller::CLI
case Args::Type::SkipDependencies:
return Argument{ type, Resource::String::SkipDependenciesArgumentDescription, ArgumentType::Flag, false };
case Args::Type::IgnoreLocalArchiveMalwareScan:
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::AdminSetting::LocalArchiveMalwareScanOverride };
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::BoolAdminSetting::LocalArchiveMalwareScanOverride };
case Args::Type::SourceName:
return Argument{ type, Resource::String::SourceNameArgumentDescription, ArgumentType::Positional, false };
case Args::Type::SourceArg:
Expand DownExpand Up@@ -379,6 +388,10 @@ namespace AppInstaller::CLI
return Argument{ type, Resource::String::AllowRebootArgumentDescription, ArgumentType::Flag };
case Args::Type::IgnoreResumeLimit:
return Argument{ type, Resource::String::IgnoreResumeLimitArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Resume };
case Args::Type::Proxy:
return Argument{ type, Resource::String::ProxyArgumentDescription, ArgumentType::Standard, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
case Args::Type::NoProxy:
return Argument{ type, Resource::String::NoProxyArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
default:
THROW_HR(E_UNEXPECTED);
}
Expand All@@ -394,6 +407,8 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
args.emplace_back(Args::Type::DisableInteractivity, Resource::String::DisableInteractivityArgumentDescription, ArgumentType::Flag, false);
args.push_back(ForType(Args::Type::Proxy));
args.push_back(ForType(Args::Type::NoProxy));
}

std::string Argument::GetUsageString() const
Expand Down
12 changes: 8 additions & 4 deletions src/AppInstallerCLICore/Argument.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,7 @@ namespace AppInstaller::CLI
PurgePreserve = 0x4,
PinType = 0x8,
StubType = 0x10,
Proxy = 0x20,

// This must always be at the end
Max
Expand DownExpand Up@@ -211,7 +212,7 @@ namespace AppInstaller::CLI
Argument::Visibility GetVisibility() const;
Settings::ExperimentalFeature::Feature Feature() const { return m_feature; }
Settings::TogglePolicy::Policy GroupPolicy() const { return m_groupPolicy; }
Settings::AdminSetting AdminSetting() const { return m_adminSetting; }
Settings::BoolAdminSetting AdminSetting() const { return m_adminSetting; }

Argument& SetRequired(bool required) { m_required = required; return *this; }
Argument& SetCountLimit(size_t countLimit) { m_countLimit = countLimit; return *this; }
Expand All@@ -237,12 +238,15 @@ namespace AppInstaller::CLI
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, bool required, Settings::ExperimentalFeature::Feature feature) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_required(required), m_feature(feature) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::ExperimentalFeature::Feature feature, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_feature(feature), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

ArgumentCommon m_argCommon;
Resource::StringId m_desc;
bool m_required = false;
Expand All@@ -251,6 +255,6 @@ namespace AppInstaller::CLI
size_t m_countLimit = 1;
Settings::ExperimentalFeature::Feature m_feature = Settings::ExperimentalFeature::Feature::None;
Settings::TogglePolicy::Policy m_groupPolicy = Settings::TogglePolicy::Policy::None;
Settings::AdminSetting m_adminSetting = Settings::AdminSetting::Unknown;
Settings::BoolAdminSetting m_adminSetting = Settings::BoolAdminSetting::Unknown;
};
}
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Command.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -637,7 +637,7 @@ namespace AppInstaller::CLI
throw GroupPolicyException(arg.GroupPolicy());
}

if (arg.AdminSetting() != AdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
if (arg.AdminSetting() != BoolAdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
{
auto setting = Settings::AdminSettingToString(arg.AdminSetting());
AICLI_LOG(CLI, Error, << "Trying to use argument: " << arg.Name() << " disabled by admin setting " << setting);
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLICore/Commands/DownloadCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,8 +36,8 @@ namespace AppInstaller::CLI
Argument::ForType(Args::Type::CustomHeader),
Argument::ForType(Args::Type::AuthenticationMode),
Argument::ForType(Args::Type::AuthenticationAccount),
Argument::ForType(Execution::Args::Type::AcceptPackageAgreements),
Argument::ForType(Execution::Args::Type::AcceptSourceAgreements),
Argument::ForType(Args::Type::AcceptPackageAgreements),
Argument::ForType(Args::Type::AcceptSourceAgreements),
};
}

Expand Down
10 changes: 9 additions & 1 deletion src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,13 +124,21 @@ namespace AppInstaller::CLI
Execution::TableOutput<2> adminSettingsTable{ context.Reporter, { Resource::String::AdminSettingHeader, Resource::String::StateHeader } };

// Output the admin settings.
for (const auto& setting : Settings::GetAllAdminSettings())
for (const auto& setting : Settings::GetAllBoolAdminSettings())
{
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
Resource::LocString{ IsAdminSettingEnabled(setting) ? Resource::String::StateEnabled : Resource::String::StateDisabled }
});
}
for (const auto& setting : Settings::GetAllStringAdminSettings())
{
auto settingValue = GetAdminSetting(setting);
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
settingValue ? Utility::LocIndString{ settingValue.value() } : Resource::LocString{ Resource::String::StateDisabled }
});
}
adminSettingsTable.Complete();
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Add support for proxies #190 by florelis · Pull Request #4203 · microsoft/winget-cli · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2f4391b
Add admin setting for enabling proxy
florelis Feb 15, 2024
b7f8153
Add proxy argument
florelis Feb 16, 2024
b2d9f31
Add group policy
florelis Feb 17, 2024
d729041
Fix bad name copy
florelis Feb 17, 2024
426a5f3
Add policy for default proxy
florelis Feb 21, 2024
f795ce2
Add proxy to context
florelis Feb 21, 2024
4d73e74
Add experimental feature
florelis Feb 22, 2024
59b0a5f
Pass proxy info to some places it is needed
florelis Feb 23, 2024
d002528
Add proxy info to sources
florelis Feb 23, 2024
7caaa86
Add admin setting for default proxy
florelis Feb 24, 2024
1a588b0
Use admin setting for proxy
florelis Feb 24, 2024
682e07e
Add to info, export
florelis Feb 24, 2024
2f843c0
Add proxy to settings schema experimental features
florelis Feb 26, 2024
e984f7f
Typo
florelis Feb 26, 2024
f5fa5f1
Merge branch 'master' into proxy
florelis Feb 26, 2024
284a1ce
Fix id
florelis Feb 26, 2024
17264b7
missing ;
florelis Feb 26, 2024
8a11d7c
Use existing httpclienthelper
florelis Feb 27, 2024
3172238
Fix string id
florelis Feb 27, 2024
2a2def3
Merge branch 'master' into proxy
florelis Feb 27, 2024
2e065e6
Make proxy settings global
florelis Feb 29, 2024
48872d5
Make proxy arguments common
florelis Feb 29, 2024
87dba88
Update doc/admx/en-US/DesktopAppInstaller.adml
florelis Mar 11, 2024
d20d685
Fix set default proxy
florelis Mar 11, 2024
0d92842
Move setting proxy to HttpClientHelper constructor
florelis Mar 11, 2024
84fb0da
Add to settings.md
florelis Mar 11, 2024
193d2eb
Update settings schema
florelis Mar 11, 2024
25facf1
Fix arg name
florelis Mar 11, 2024
e0fdcf7
Reset bool admin settings
florelis Mar 11, 2024
3d8f87a
LocIndString
florelis Mar 11, 2024
48d2ab5
Update src/AppInstallerCLICore/Commands/SettingsCommand.cpp
florelis Mar 14, 2024
97e9415
Update src/AppInstallerCLICore/Workflows/SettingsFlow.cpp
florelis Mar 14, 2024
ce47cf5
PR suggestion
florelis Mar 14, 2024
fb18813
Missing )
florelis Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -312,3 +312,14 @@ You can enable the feature as shown below.
"configuration03": true
},
```

### proxy

This feature enables the use of web proxies.
You can enable the feature as shown below.

```json
"experimentalFeatures": {
"proxy": true
},
```
17 changes: 17 additions & 0 deletions doc/admx/DesktopAppInstaller.admx
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,5 +166,22 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="EnableWindowsPackageManagerProxyCommandLineOptions" class="Machine" displayName="$(string.EnableWindowsPackageManagerProxyCommandLineOptions)" explainText="$(string.EnableWindowsPackageManagerProxyCommandLineOptionsExplanation)" key="Software\Policies\Microsoft\Windows\AppInstaller" valueName="EnableWindowsPackageManagerProxyCommandLineOptions">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="WindowsPackageManagerDefaultProxy" class="Machine" displayName="$(string.WindowsPackageManagerDefaultProxy)" explainText="$(string.WindowsPackageManagerDefaultProxyExplanation)" presentation="$(presentation.WindowsPackageManagerDefaultProxy)" key="Software\Policies\Microsoft\Windows\AppInstaller">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<elements>
<text id="WindowsPackageManagerDefaultProxy" valueName="DefaultProxy" />
</elements>
</policy>
</policies>
</policyDefinitions>
20 changes: 19 additions & 1 deletion doc/admx/en-US/DesktopAppInstaller.adml
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,7 +100,7 @@ If you disable or do not configure this setting, users will not be able to insta

If you disable this policy, users will not be able execute the Windows Package Manager CLI, and PowerShell cmdlets.

If you enable, or do not configuring this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).
If you enable, or do not configure this policy, users will be able to execute the Windows Package Manager CLI commands, and PowerShell cmdlets. (Provided “Enable App Installer” policy is not disabled).

This policy does not override the “Enable App Installer” policy.</string>
<string id="EnableWindowsPackageManagerConfiguration">Enable Windows Package Manager Configuration</string>
Expand All@@ -109,6 +109,19 @@ If you disable or do not configure this setting, users will not be able to insta
If you enable or do not configure this setting, users will be able to use the Windows Package Manager configuration feature.

If you disable this setting, users will not be able to use the Windows Package Manager configuration feature.</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptions">Enable Windows Package Manager Proxy command line options</string>
<string id="EnableWindowsPackageManagerProxyCommandLineOptionsExplanation">
This policy controls whether the Windows Package Manager usage of proxy can be configured by users through the command line.

If you enable this setting, users will be able to configure the Windows Package Manager's use of proxy through the command line.

If you disable or do not configure this setting, users will not be able to to configure the Windows Package Manager's use of proxy through the command line.</string>
<string id="WindowsPackageManagerDefaultProxy">Set Windows Package Manager Default Proxy</string>
<string id="WindowsPackageManagerDefaultProxyExplanation">This policy controls the default proxy used by the Windows Package Manager.

If you disable or do not configure this setting, no proxy will be used by default.

If you enable this setting, the specified proxy will be used by default.</string>
</stringTable>
<presentationTable>
<presentation id="SourceAutoUpdateInterval">
Expand All@@ -120,6 +133,11 @@ If you disable this setting, users will not be able to use the Windows Package M
<presentation id="AllowedSources">
<listBox refId="AllowedSources" required="false">Allowed Sources: </listBox>
</presentation>
<presentation id="WindowsPackageManagerDefaultProxy">
<textBox refId="WindowsPackageManagerDefaultProxy">
<label>Default Proxy</label>
</textBox>
</presentation>
</presentationTable>
</resources>
</policyDefinitionResources>
20 changes: 19 additions & 1 deletion schemas/JSON/settings/settings.export.schema.0.1.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,26 @@
"description": "Enable installing local manifests.",
"type": "boolean",
"default": false
},
"InstallerHashOverride": {
"description": "Enable overriding installer hash validation.",
"type": "boolean",
"default": false
},
"LocalArchiveMalwareScanOverride": {
"description": "Enable overriding malware scan for local archives.",
"type": "boolean",
"default": false
},
"ProxyCommandLineOptions": {
"description": "Enable using command line options for proxy.",
"type": "boolean",
"default": false
},
"DefaultProxy": {
"description": "Default proxy.",
"type": "string"
}
}
},
"UserSettingsFile": {
"description": "Path for the winget's user settings file.",
Expand Down
9 changes: 7 additions & 2 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,8 +266,13 @@
"type": "boolean",
"default": false
},
"configuration": {
"description": "Enable support for configuration",
"configuration03": {
"description": "Enable support for configuration schema 0.3",
"type": "boolean",
"default": false
},
"proxy": {
Comment thread
florelis marked this conversation as resolved.
"description": "Enable support for proxies",
"type": "boolean",
"default": false
}
Expand Down
21 changes: 18 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,6 +151,10 @@ namespace AppInstaller::CLI
return { type, "enable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::AdminSettingDisable:
return { type, "disable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::EnableDisable };
case Execution::Args::Type::SettingName:
return { type, "setting"_liv };
case Execution::Args::Type::SettingValue:
return { type, "value"_liv };

// Upgrade command
case Execution::Args::Type::All:
Expand DownExpand Up@@ -233,6 +237,11 @@ namespace AppInstaller::CLI
case Execution::Args::Type::AcceptSourceAgreements:
return { type, "accept-source-agreements"_liv, ArgTypeCategory::ExtendedSource };

case Execution::Args::Type::Proxy:
return { type, "proxy"_liv, ArgTypeCategory::CopyValueToSubContext, ArgTypeExclusiveSet::Proxy };
case Execution::Args::Type::NoProxy:
return { type, "no-proxy"_liv, ArgTypeCategory::CopyFlagToSubContext, ArgTypeExclusiveSet::Proxy };

case Execution::Args::Type::ToolVersion:
return { type, "version"_liv, 'v' };

Expand DownExpand Up@@ -268,7 +277,7 @@ namespace AppInstaller::CLI
case Args::Type::MultiQuery:
return Argument{ type, Resource::String::MultiQueryArgumentDescription, ArgumentType::Positional }.SetCountLimit(128);
case Args::Type::Manifest:
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::AdminSetting::LocalManifestFiles };
return Argument{ type, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help, Settings::TogglePolicy::Policy::LocalManifestFiles, Settings::BoolAdminSetting::LocalManifestFiles };
case Args::Type::Id:
return Argument{ type, Resource::String::IdArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help };
case Args::Type::Name:
Expand DownExpand Up@@ -308,7 +317,7 @@ namespace AppInstaller::CLI
case Args::Type::InstallLocation:
return Argument{ type, Resource::String::LocationArgumentDescription, ArgumentType::Standard };
case Args::Type::HashOverride:
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::AdminSetting::InstallerHashOverride };
return Argument{ type, Resource::String::HashOverrideArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::HashOverride, Settings::BoolAdminSetting::InstallerHashOverride };
case Args::Type::AcceptPackageAgreements:
return Argument{ type, Resource::String::AcceptPackageAgreementsArgumentDescription, ArgumentType::Flag };
case Args::Type::NoUpgrade:
Expand All@@ -324,7 +333,7 @@ namespace AppInstaller::CLI
case Args::Type::SkipDependencies:
return Argument{ type, Resource::String::SkipDependenciesArgumentDescription, ArgumentType::Flag, false };
case Args::Type::IgnoreLocalArchiveMalwareScan:
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::AdminSetting::LocalArchiveMalwareScanOverride };
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::BoolAdminSetting::LocalArchiveMalwareScanOverride };
case Args::Type::SourceName:
return Argument{ type, Resource::String::SourceNameArgumentDescription, ArgumentType::Positional, false };
case Args::Type::SourceArg:
Expand DownExpand Up@@ -379,6 +388,10 @@ namespace AppInstaller::CLI
return Argument{ type, Resource::String::AllowRebootArgumentDescription, ArgumentType::Flag };
case Args::Type::IgnoreResumeLimit:
return Argument{ type, Resource::String::IgnoreResumeLimitArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Resume };
case Args::Type::Proxy:
return Argument{ type, Resource::String::ProxyArgumentDescription, ArgumentType::Standard, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
case Args::Type::NoProxy:
return Argument{ type, Resource::String::NoProxyArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::Proxy, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
default:
THROW_HR(E_UNEXPECTED);
}
Expand All@@ -394,6 +407,8 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
args.emplace_back(Args::Type::DisableInteractivity, Resource::String::DisableInteractivityArgumentDescription, ArgumentType::Flag, false);
args.push_back(ForType(Args::Type::Proxy));
args.push_back(ForType(Args::Type::NoProxy));
}

std::string Argument::GetUsageString() const
Expand Down
12 changes: 8 additions & 4 deletions src/AppInstallerCLICore/Argument.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,7 @@ namespace AppInstaller::CLI
PurgePreserve = 0x4,
PinType = 0x8,
StubType = 0x10,
Proxy = 0x20,

// This must always be at the end
Max
Expand DownExpand Up@@ -211,7 +212,7 @@ namespace AppInstaller::CLI
Argument::Visibility GetVisibility() const;
Settings::ExperimentalFeature::Feature Feature() const { return m_feature; }
Settings::TogglePolicy::Policy GroupPolicy() const { return m_groupPolicy; }
Settings::AdminSetting AdminSetting() const { return m_adminSetting; }
Settings::BoolAdminSetting AdminSetting() const { return m_adminSetting; }

Argument& SetRequired(bool required) { m_required = required; return *this; }
Argument& SetCountLimit(size_t countLimit) { m_countLimit = countLimit; return *this; }
Expand All@@ -237,12 +238,15 @@ namespace AppInstaller::CLI
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, bool required, Settings::ExperimentalFeature::Feature feature) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_required(required), m_feature(feature) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::AdminSetting adminSetting) :
Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Argument::Visibility visibility, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

Argument(Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Settings::ExperimentalFeature::Feature feature, Settings::TogglePolicy::Policy groupPolicy, Settings::BoolAdminSetting adminSetting) :
m_argCommon(ArgumentCommon::ForType(execArgType)), m_desc(std::move(desc)), m_type(type), m_feature(feature), m_groupPolicy(groupPolicy), m_adminSetting(adminSetting) {}

ArgumentCommon m_argCommon;
Resource::StringId m_desc;
bool m_required = false;
Expand All@@ -251,6 +255,6 @@ namespace AppInstaller::CLI
size_t m_countLimit = 1;
Settings::ExperimentalFeature::Feature m_feature = Settings::ExperimentalFeature::Feature::None;
Settings::TogglePolicy::Policy m_groupPolicy = Settings::TogglePolicy::Policy::None;
Settings::AdminSetting m_adminSetting = Settings::AdminSetting::Unknown;
Settings::BoolAdminSetting m_adminSetting = Settings::BoolAdminSetting::Unknown;
};
}
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Command.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -637,7 +637,7 @@ namespace AppInstaller::CLI
throw GroupPolicyException(arg.GroupPolicy());
}

if (arg.AdminSetting() != AdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
if (arg.AdminSetting() != BoolAdminSetting::Unknown && !Settings::IsAdminSettingEnabled(arg.AdminSetting()) && execArgs.Contains(arg.ExecArgType()))
{
auto setting = Settings::AdminSettingToString(arg.AdminSetting());
AICLI_LOG(CLI, Error, << "Trying to use argument: " << arg.Name() << " disabled by admin setting " << setting);
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLICore/Commands/DownloadCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,8 +36,8 @@ namespace AppInstaller::CLI
Argument::ForType(Args::Type::CustomHeader),
Argument::ForType(Args::Type::AuthenticationMode),
Argument::ForType(Args::Type::AuthenticationAccount),
Argument::ForType(Execution::Args::Type::AcceptPackageAgreements),
Argument::ForType(Execution::Args::Type::AcceptSourceAgreements),
Argument::ForType(Args::Type::AcceptPackageAgreements),
Argument::ForType(Args::Type::AcceptSourceAgreements),
};
}

Expand Down
10 changes: 9 additions & 1 deletion src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,13 +124,21 @@ namespace AppInstaller::CLI
Execution::TableOutput<2> adminSettingsTable{ context.Reporter, { Resource::String::AdminSettingHeader, Resource::String::StateHeader } };

// Output the admin settings.
for (const auto& setting : Settings::GetAllAdminSettings())
for (const auto& setting : Settings::GetAllBoolAdminSettings())
{
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
Resource::LocString{ IsAdminSettingEnabled(setting) ? Resource::String::StateEnabled : Resource::String::StateDisabled }
});
}
for (const auto& setting : Settings::GetAllStringAdminSettings())
{
auto settingValue = GetAdminSetting(setting);
adminSettingsTable.OutputLine({
std::string{ AdminSettingToString(setting)},
settingValue ? Utility::LocIndString{ settingValue.value() } : Resource::LocString{ Resource::String::StateDisabled }
});
}
adminSettingsTable.Complete();
}

Expand Down
Loading