diff --git a/doc/Settings.md b/doc/Settings.md index f593fc946f..027c0066ab 100644 --- a/doc/Settings.md +++ b/doc/Settings.md @@ -200,6 +200,21 @@ The `purgePortablePackage` behavior affects the default behavior for uninstallin }, ``` +## Configure Behavior + +The `configureBehavior` settings affect the default behavior of applying a configuration. + +### Default Module Root +The `defaultModuleRoot` behavior affects the default root directory where modules are installed to. Defaults to `%LOCALAPPDATA%/Microsoft/WinGet/Configuration/Modules` if value is not set or is invalid. + +> Note: This setting value must be an absolute path. + +```json + "configureBehavior": { + "defaultModuleRoot": "C:/Program Files/Modules/" + }, +``` + ## Telemetry The `telemetry` settings control whether winget writes ETW events that may be sent to Microsoft on a default installation of Windows. diff --git a/schemas/JSON/settings/settings.schema.0.2.json b/schemas/JSON/settings/settings.schema.0.2.json index 4a1f547113..099ebe8080 100644 --- a/schemas/JSON/settings/settings.schema.0.2.json +++ b/schemas/JSON/settings/settings.schema.0.2.json @@ -198,8 +198,8 @@ } } }, - "ConfigurationBehavior": { - "description": "Configuration settings", + "ConfigureBehavior": { + "description": "Configure settings", "type": "object", "properties": { "defaultModuleRoot": { @@ -208,7 +208,7 @@ "maxLength": 32767 } } - } + }, "DownloadBehavior": { "description": "Download settings", "type": "object", diff --git a/src/AppInstallerCLICore/ConfigurationCommon.cpp b/src/AppInstallerCLICore/ConfigurationCommon.cpp index f00476c330..4a6a4c1e3c 100644 --- a/src/AppInstallerCLICore/ConfigurationCommon.cpp +++ b/src/AppInstallerCLICore/ConfigurationCommon.cpp @@ -48,7 +48,7 @@ namespace AppInstaller::CLI } } - std::filesystem::path defaultModuleRoot = Settings::User().Get(); + std::filesystem::path defaultModuleRoot = Settings::User().Get(); if (!defaultModuleRoot.empty()) { diff --git a/src/AppInstallerCLIE2ETests/ConfigureCommand.cs b/src/AppInstallerCLIE2ETests/ConfigureCommand.cs index 0d436389f5..6f7eaa4d3f 100644 --- a/src/AppInstallerCLIE2ETests/ConfigureCommand.cs +++ b/src/AppInstallerCLIE2ETests/ConfigureCommand.cs @@ -124,7 +124,7 @@ public void ConfigureFromTestRepo_SettingsDefaultModuleRoot() TestCommon.EnsureModuleState(Constants.SimpleTestModuleName, present: false); string moduleTestDir = TestCommon.GetRandomTestDir(); - WinGetSettingsHelper.ConfigureConfigurationBehavior(Constants.DefaultModuleRoot, moduleTestDir); + WinGetSettingsHelper.ConfigureConfigureBehavior(Constants.DefaultModuleRoot, moduleTestDir); string args = TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo_Location.yml"); var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, args); diff --git a/src/AppInstallerCLIE2ETests/Helpers/WinGetSettingsHelper.cs b/src/AppInstallerCLIE2ETests/Helpers/WinGetSettingsHelper.cs index f788a6e1db..3c66529d3e 100644 --- a/src/AppInstallerCLIE2ETests/Helpers/WinGetSettingsHelper.cs +++ b/src/AppInstallerCLIE2ETests/Helpers/WinGetSettingsHelper.cs @@ -113,7 +113,7 @@ public static void ConfigureInstallBehavior(string settingName, string value) /// /// Setting name. /// Setting value. - public static void ConfigureConfigurationBehavior(string settingName, string value) + public static void ConfigureConfigureBehavior(string settingName, string value) { JObject settingsJson = GetJsonSettingsObject("configureBehavior"); var configureBehavior = settingsJson["configureBehavior"]; diff --git a/src/AppInstallerCLITests/UserSettings.cpp b/src/AppInstallerCLITests/UserSettings.cpp index 2363624074..3d0820f8d5 100644 --- a/src/AppInstallerCLITests/UserSettings.cpp +++ b/src/AppInstallerCLITests/UserSettings.cpp @@ -526,17 +526,17 @@ TEST_CASE("SettingsDownloadDefaultDirectory", "[settings]") } } -TEST_CASE("SettingsConfigurationDefaultModuleRoot", "[settings]") +TEST_CASE("SettingsConfigureDefaultModuleRoot", "[settings]") { auto again = DeleteUserSettingsFiles(); SECTION("Valid path") { - std::string_view json = R"({ "configurationBehavior": { "defaultModuleRoot": "C:/Foo/Bar" } })"; + std::string_view json = R"({ "configureBehavior": { "defaultModuleRoot": "C:/Foo/Bar" } })"; SetSetting(Stream::PrimaryUserSettings, json); UserSettingsTest userSettingTest; - REQUIRE(userSettingTest.Get() == "C:/Foo/Bar"); + REQUIRE(userSettingTest.Get() == "C:/Foo/Bar"); REQUIRE(userSettingTest.GetWarnings().size() == 0); } } diff --git a/src/AppInstallerCommonCore/Public/winget/UserSettings.h b/src/AppInstallerCommonCore/Public/winget/UserSettings.h index 51f9d9b46f..39ba54e7f7 100644 --- a/src/AppInstallerCommonCore/Public/winget/UserSettings.h +++ b/src/AppInstallerCommonCore/Public/winget/UserSettings.h @@ -109,7 +109,7 @@ namespace AppInstaller::Settings // Download behavior DownloadDefaultDirectory, // Configuration behavior - ConfigurationDefaultModuleRoot, + ConfigureDefaultModuleRoot, // Interactivity InteractivityDisable, #ifndef AICLI_DISABLE_TEST_HOOKS @@ -188,7 +188,7 @@ namespace AppInstaller::Settings // Download behavior SETTINGMAPPING_SPECIALIZATION(Setting::DownloadDefaultDirectory, std::string, std::filesystem::path, {}, ".downloadBehavior.defaultDownloadDirectory"sv); // Configuration behavior - SETTINGMAPPING_SPECIALIZATION(Setting::ConfigurationDefaultModuleRoot, std::string, std::filesystem::path, {}, ".configurationBehavior.defaultModuleRoot"sv); + SETTINGMAPPING_SPECIALIZATION(Setting::ConfigureDefaultModuleRoot, std::string, std::filesystem::path, {}, ".configureBehavior.defaultModuleRoot"sv); // Network SETTINGMAPPING_SPECIALIZATION(Setting::NetworkDownloader, std::string, InstallerDownloader, InstallerDownloader::Default, ".network.downloader"sv); diff --git a/src/AppInstallerCommonCore/UserSettings.cpp b/src/AppInstallerCommonCore/UserSettings.cpp index 246bf9b885..d6879e9b9a 100644 --- a/src/AppInstallerCommonCore/UserSettings.cpp +++ b/src/AppInstallerCommonCore/UserSettings.cpp @@ -401,7 +401,7 @@ namespace AppInstaller::Settings return ValidatePathValue(value); } - WINGET_VALIDATE_SIGNATURE(ConfigurationDefaultModuleRoot) + WINGET_VALIDATE_SIGNATURE(ConfigureDefaultModuleRoot) { return ValidatePathValue(value); }