From 8c8cfeded688b388a42f722c66f54a35e10d4998 Mon Sep 17 00:00:00 2001 From: JohnMcPMS Date: Mon, 20 Sep 2021 17:39:45 -0700 Subject: [PATCH] Create machinery for disabling experimental features; disable some verbose logs --- src/AppInstallerCLICore/AppInstallerCLICore.vcxproj | 5 +++++ src/AppInstallerCLICore/Commands/FeaturesCommand.cpp | 4 ++++ src/AppInstallerCLICore/Core.cpp | 6 +++--- src/AppInstallerCLICore/Resources.h | 1 + .../Shared/Strings/en-us/winget.resw | 4 ++++ src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj | 5 +++++ src/AppInstallerCommonCore/ExperimentalFeature.cpp | 6 ++++++ src/AppInstallerCommonCore/GroupPolicy.cpp | 2 +- src/AppInstallerCommonCore/Settings.cpp | 2 +- src/AppInstallerCommonCore/UserSettings.cpp | 8 ++++---- 10 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj index 32a91e24e1..6156f71782 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj @@ -231,6 +231,11 @@ AICLI_DISABLE_TEST_HOOKS;%(PreprocessorDefinitions) + + + WINGET_DISABLE_EXPERIMENTAL_FEATURES;%(PreprocessorDefinitions) + + diff --git a/src/AppInstallerCLICore/Commands/FeaturesCommand.cpp b/src/AppInstallerCLICore/Commands/FeaturesCommand.cpp index 3a4eb8013a..a273681f9e 100644 --- a/src/AppInstallerCLICore/Commands/FeaturesCommand.cpp +++ b/src/AppInstallerCLICore/Commands/FeaturesCommand.cpp @@ -27,6 +27,9 @@ namespace AppInstaller::CLI void FeaturesCommand::ExecuteInternal(Execution::Context& context) const { +#ifdef WINGET_DISABLE_EXPERIMENTAL_FEATURES + context.Reporter.Info() << Resource::String::FeaturesMessageDisabledByBuild << std::endl; +#else if (GroupPolicies().IsEnabled(TogglePolicy::Policy::ExperimentalFeatures) && GroupPolicies().IsEnabled(TogglePolicy::Policy::Settings)) { @@ -61,5 +64,6 @@ namespace AppInstaller::CLI // Better work hard to get some out there! context.Reporter.Info() << Resource::String::NoExperimentalFeaturesMessage << std::endl; } +#endif } } diff --git a/src/AppInstallerCLICore/Core.cpp b/src/AppInstallerCLICore/Core.cpp index d9a3b3af8d..e2ac443969 100644 --- a/src/AppInstallerCLICore/Core.cpp +++ b/src/AppInstallerCLICore/Core.cpp @@ -48,7 +48,7 @@ namespace AppInstaller::CLI // Enable all logging for this phase; we will update once we have the arguments Logging::Log().EnableChannel(Logging::Channel::All); - Logging::Log().SetLevel(Logging::Level::Verbose); + Logging::Log().SetLevel(Logging::Level::Info); Logging::AddFileLogger(); Logging::EnableWilFailureTelemetry(); @@ -100,9 +100,9 @@ namespace AppInstaller::CLI command->ParseArguments(invocation, context.Args); // Change logging level to Info if Verbose not requested - if (!context.Args.Contains(Execution::Args::Type::VerboseLogs)) + if (context.Args.Contains(Execution::Args::Type::VerboseLogs)) { - Logging::Log().SetLevel(Logging::Level::Info); + Logging::Log().SetLevel(Logging::Level::Verbose); } context.UpdateForArgs(); diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index b96790095d..ea1680e6c3 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -65,6 +65,7 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(FeaturesFeature); WINGET_DEFINE_RESOURCE_STRINGID(FeaturesLink); WINGET_DEFINE_RESOURCE_STRINGID(FeaturesMessage); + WINGET_DEFINE_RESOURCE_STRINGID(FeaturesMessageDisabledByBuild); WINGET_DEFINE_RESOURCE_STRINGID(FeaturesMessageDisabledByPolicy); WINGET_DEFINE_RESOURCE_STRINGID(FeaturesProperty); WINGET_DEFINE_RESOURCE_STRINGID(FeaturesStatus); diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index a0d08c95d5..004b4e579a 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -1165,4 +1165,8 @@ Please specify one of them using the `--source` option to proceed. No packages were found among the working sources. + + This is a stable release of the Windows Package Manager. If you would like to try experimental features, please install a pre-release build. Instructions are available on GitHub at https://github.com/microsoft/winget-cli. + {Locked="Windows Package Manager","GitHub","https://github.com/microsoft/winget-cli"} + \ No newline at end of file diff --git a/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj b/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj index 50614574f8..5a472d3320 100644 --- a/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj +++ b/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj @@ -264,6 +264,11 @@ AICLI_DISABLE_TEST_HOOKS;%(PreprocessorDefinitions) + + + WINGET_DISABLE_EXPERIMENTAL_FEATURES;%(PreprocessorDefinitions) + + diff --git a/src/AppInstallerCommonCore/ExperimentalFeature.cpp b/src/AppInstallerCommonCore/ExperimentalFeature.cpp index 79405e9378..fa428ed99f 100644 --- a/src/AppInstallerCommonCore/ExperimentalFeature.cpp +++ b/src/AppInstallerCommonCore/ExperimentalFeature.cpp @@ -17,6 +17,11 @@ namespace AppInstaller::Settings return true; } +#ifdef WINGET_DISABLE_EXPERIMENTAL_FEATURES + UNREFERENCED_PARAMETER(userSettings); + return false; +#else + if (!GroupPolicies().IsEnabled(TogglePolicy::Policy::ExperimentalFeatures)) { AICLI_LOG(Core, Info, << @@ -40,6 +45,7 @@ namespace AppInstaller::Settings default: THROW_HR(E_UNEXPECTED); } +#endif } } diff --git a/src/AppInstallerCommonCore/GroupPolicy.cpp b/src/AppInstallerCommonCore/GroupPolicy.cpp index 3a9a638a18..9641465dcb 100644 --- a/src/AppInstallerCommonCore/GroupPolicy.cpp +++ b/src/AppInstallerCommonCore/GroupPolicy.cpp @@ -57,7 +57,7 @@ namespace AppInstaller::Settings return std::nullopt; } - AICLI_LOG(Core, Info, << "Found policy '" << valueName << "', Value: " << *intValue); + AICLI_LOG(Core, Verbose, << "Found policy '" << valueName << "', Value: " << *intValue); return (bool)*intValue; } diff --git a/src/AppInstallerCommonCore/Settings.cpp b/src/AppInstallerCommonCore/Settings.cpp index 78da315022..d44de54580 100644 --- a/src/AppInstallerCommonCore/Settings.cpp +++ b/src/AppInstallerCommonCore/Settings.cpp @@ -25,7 +25,7 @@ namespace AppInstaller::Settings void LogSettingAction(std::string_view action, const StreamDefinition& def) { - AICLI_LOG(Core, Info, << "Setting action: " << action << ", Type: " << ToString(def.Type) << ", Name: " << def.Path); + AICLI_LOG(Core, Verbose, << "Setting action: " << action << ", Type: " << ToString(def.Type) << ", Name: " << def.Path); } // A settings container. diff --git a/src/AppInstallerCommonCore/UserSettings.cpp b/src/AppInstallerCommonCore/UserSettings.cpp index 57347aaf97..5e41c72c10 100644 --- a/src/AppInstallerCommonCore/UserSettings.cpp +++ b/src/AppInstallerCommonCore/UserSettings.cpp @@ -121,12 +121,12 @@ namespace AppInstaller::Settings // Add it to the map settings[S].emplace( std::forward::value_t>(validatedValue.value())); - AICLI_LOG(Core, Info, << "Valid setting from Group Policy. Field: " << path << " Value: " << GetValueString(policyValue.value())); + AICLI_LOG(Core, Verbose, << "Valid setting from Group Policy. Field: " << path << " Value: " << GetValueString(policyValue.value())); } else { auto valueAsString = GetValueString(policyValue.value()); - AICLI_LOG(Core, Info, << "Invalid setting from Group Policy. Field: " << path << " Value: " << valueAsString); + AICLI_LOG(Core, Error, << "Invalid setting from Group Policy. Field: " << path << " Value: " << valueAsString); warnings.emplace_back(StringResource::String::SettingsWarningInvalidValueFromPolicy, path, valueAsString); } @@ -148,7 +148,7 @@ namespace AppInstaller::Settings // Finally add it to the map settings[S].emplace( std::forward::value_t>(validatedValue.value())); - AICLI_LOG(Core, Info, << "Valid setting. Field: " << path << " Value: " << GetValueString(jsonValue.value())); + AICLI_LOG(Core, Verbose, << "Valid setting. Field: " << path << " Value: " << GetValueString(jsonValue.value())); } else { @@ -165,7 +165,7 @@ namespace AppInstaller::Settings } else { - AICLI_LOG(Core, Info, << "Setting " << path << " not found. Using default"); + AICLI_LOG(Core, Verbose, << "Setting " << path << " not found. Using default"); } }