Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for 1.2 Schema Additions #2028

Merged
merged 19 commits into from
Apr 1, 2022
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ Please specify one of them using the `--source` option to proceed.</value>
<value>Retains all files and directories created by the package (portable)</value>
</data>
<data name="PurgeArgumentDescription" xml:space="preserve">
<value>Deletes all files and directories created by the package (portable)</value>
<value>Deletes all files and directories in the package directory (portable)</value>
</data>
<data name="RenameArgumentDescription" xml:space="preserve">
<value>The value to rename the executable file (portable)</value>
Expand Down
13 changes: 13 additions & 0 deletions src/AppInstallerCLITests/UserSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,16 @@ TEST_CASE("SettingsExperimentalCmd", "[settings]")
REQUIRE(userSettingTest.GetWarnings().size() == 0);
}
}

TEST_CASE("SettingsPortableAppRoot", "[settings]")
{
SECTION("Relative path")
{
std::string_view json = R"({ "installBehavior": { "portableAppUserRoot": %LOCALAPPDATA%/Portable/Root } })";
SetSetting(Stream::PrimaryUserSettings, json);
UserSettingsTest userSettingTest;

REQUIRE(userSettingTest.Get<Setting::PortableAppUserRoot>().empty());
REQUIRE(userSettingTest.GetWarnings().size() == 1);
}
}
4 changes: 2 additions & 2 deletions src/AppInstallerCommonCore/Public/winget/UserSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ namespace AppInstaller::Settings
SETTINGMAPPING_SPECIALIZATION(Setting::InstallLocalePreference, std::vector<std::string>, std::vector<std::string>, {}, ".installBehavior.preferences.locale"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::InstallLocaleRequirement, std::vector<std::string>, std::vector<std::string>, {}, ".installBehavior.requirements.locale"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::InstallIgnoreWarnings, bool, bool, false, ".installBehavior.ignoreWarnings"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::PortableAppUserRoot, std::string, std::string, {}, ".installBehavior.portableAppUserRoot"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::PortableAppMachineRoot, std::string, std::string, {}, ".installBehavior.portableAppMachineRoot"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::PortableAppUserRoot, std::string, std::filesystem::path, {}, ".installBehavior.portableAppUserRoot"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::PortableAppMachineRoot, std::string, std::filesystem::path, {}, ".installBehavior.portableAppMachineRoot"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::UninstallPurgePortableApp, bool, bool, false, ".uninstallBehavior.purgePortableApp"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::EFDirectMSI, bool, bool, false, ".experimentalFeatures.directMSI"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::EnableSelfInitiatedMinidump, bool, bool, false, ".debugging.enableSelfInitiatedMinidump"sv);
Expand Down
18 changes: 16 additions & 2 deletions src/AppInstallerCommonCore/UserSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,22 @@ namespace AppInstaller::Settings
WINGET_VALIDATE_PASS_THROUGH(EnableSelfInitiatedMinidump)
WINGET_VALIDATE_PASS_THROUGH(InstallIgnoreWarnings)
WINGET_VALIDATE_PASS_THROUGH(UninstallPurgePortableApp)
WINGET_VALIDATE_PASS_THROUGH(PortableAppUserRoot)
WINGET_VALIDATE_PASS_THROUGH(PortableAppMachineRoot)

ryfu-msft marked this conversation as resolved.
Show resolved Hide resolved
WINGET_VALIDATE_SIGNATURE(PortableAppUserRoot)
{
std::filesystem::path root = { value };
ryfu-msft marked this conversation as resolved.
Show resolved Hide resolved
if (!root.is_absolute())
{
return {};
}

return root;
}

WINGET_VALIDATE_SIGNATURE(PortableAppMachineRoot)
{
return SettingMapping<Setting::PortableAppUserRoot>::Validate(value);
}

WINGET_VALIDATE_SIGNATURE(InstallArchitecturePreference)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ namespace AppInstaller::Repository::Rest::Schema::V1_1::Json
// Only add when it is valid
if (installerReturnCode != 0 && returnResponse != ExpectedReturnCodeEnum::Unknown)
{
if (!installer.ExpectedReturnCodes.insert({ installerReturnCode, {returnResponse, ""} }).second)
if (!installer.ExpectedReturnCodes.insert({ installerReturnCode, { returnResponse, "" } }).second)
{
AICLI_LOG(Repo, Error, << "Expected return codes cannot have repeated value.");
return {};
Expand Down