commit 4f9ffc179d27eb03562bbbe3950f233fb22736cb
parent 146205eb1183e1c38ecf313f4a04451485e909b5
Author: yao-msft <50888816+yao-msft@users.noreply.github.com>
Date: Wed, 17 Mar 2021 16:22:43 -0700
Correct InstallModes in manifest schema (#804)
Diffstat:
9 files changed, 61 insertions(+), 19 deletions(-)
diff --git a/schemas/JSON/manifests/v1.0.0/manifest.installer.1.0.0.json b/schemas/JSON/manifests/v1.0.0/manifest.installer.1.0.0.json
@@ -72,9 +72,14 @@
"InstallModes": {
"type": [ "array", "null" ],
"items": {
- "$ref": "#/definitions/Scope"
+ "type": "string",
+ "enum": [
+ "interactive",
+ "silent",
+ "silentWithProgress"
+ ]
},
- "maxItems": 2,
+ "maxItems": 3,
"uniqueItems": true,
"description": "List of supported installer modes"
},
diff --git a/schemas/JSON/manifests/v1.0.0/manifest.singleton.1.0.0.json b/schemas/JSON/manifests/v1.0.0/manifest.singleton.1.0.0.json
@@ -85,9 +85,14 @@
"InstallModes": {
"type": [ "array", "null" ],
"items": {
- "$ref": "#/definitions/Scope"
+ "type": "string",
+ "enum": [
+ "interactive",
+ "silent",
+ "silentWithProgress"
+ ]
},
- "maxItems": 2,
+ "maxItems": 3,
"uniqueItems": true,
"description": "List of supported installer modes"
},
diff --git a/src/AppInstallerCLITests/TestData/ManifestV1-Singleton.yaml b/src/AppInstallerCLITests/TestData/ManifestV1-Singleton.yaml
@@ -26,8 +26,9 @@ MinimumOSVersion: 10.0.0.0
InstallerType: zip
Scope: machine
InstallModes:
- - user
- - machine
+ - interactive
+ - silent
+ - silentWithProgress
InstallerSwitches:
Custom: /custom
SilentWithProgress: /silentwithprogress
@@ -80,7 +81,7 @@ Installers:
SignatureSha256: 69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82
Scope: user
InstallModes:
- - user
+ - interactive
InstallerSwitches:
Custom: /c
SilentWithProgress: /sp
diff --git a/src/AppInstallerCLITests/TestData/MultiFileManifestV1/ManifestV1-MultiFile-Installer.yaml b/src/AppInstallerCLITests/TestData/MultiFileManifestV1/ManifestV1-MultiFile-Installer.yaml
@@ -8,8 +8,9 @@ MinimumOSVersion: 10.0.0.0
InstallerType: zip
Scope: machine
InstallModes:
- - user
- - machine
+ - interactive
+ - silent
+ - silentWithProgress
InstallerSwitches:
Custom: /custom
SilentWithProgress: /silentwithprogress
@@ -62,7 +63,7 @@ Installers:
SignatureSha256: 69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82
Scope: user
InstallModes:
- - user
+ - interactive
InstallerSwitches:
Custom: /c
SilentWithProgress: /sp
diff --git a/src/AppInstallerCLITests/YamlManifest.cpp b/src/AppInstallerCLITests/YamlManifest.cpp
@@ -355,7 +355,7 @@ void VerifyV1ManifestContent(const Manifest& manifest, bool isSingleton)
REQUIRE(manifest.DefaultInstallerInfo.MinOSVersion == "10.0.0.0");
REQUIRE(manifest.DefaultInstallerInfo.InstallerType == InstallerTypeEnum::Zip);
REQUIRE(manifest.DefaultInstallerInfo.Scope == ScopeEnum::Machine);
- REQUIRE(manifest.DefaultInstallerInfo.InstallModes == std::vector<ScopeEnum>{ ScopeEnum::User ,ScopeEnum::Machine });
+ REQUIRE(manifest.DefaultInstallerInfo.InstallModes == std::vector<InstallModeEnum>{ InstallModeEnum::Interactive, InstallModeEnum::Silent, InstallModeEnum::SilentWithProgress });
auto defaultSwitches = manifest.DefaultInstallerInfo.Switches;
REQUIRE(defaultSwitches.at(InstallerSwitchType::Custom) == "/custom");
@@ -404,7 +404,7 @@ void VerifyV1ManifestContent(const Manifest& manifest, bool isSingleton)
REQUIRE(installer1.Sha256 == SHA256::ConvertToBytes("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82"));
REQUIRE(installer1.SignatureSha256 == SHA256::ConvertToBytes("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82"));
REQUIRE(installer1.Scope == ScopeEnum::User);
- REQUIRE(installer1.InstallModes == std::vector<ScopeEnum>{ ScopeEnum::User });
+ REQUIRE(installer1.InstallModes == std::vector<InstallModeEnum>{ InstallModeEnum::Interactive });
auto installer1Switches = installer1.Switches;
REQUIRE(installer1Switches.at(InstallerSwitchType::Custom) == "/c");
diff --git a/src/AppInstallerCommonCore/Manifest/ManifestCommon.cpp b/src/AppInstallerCommonCore/Manifest/ManifestCommon.cpp
@@ -194,6 +194,26 @@ namespace AppInstaller::Manifest
return result;
}
+ InstallModeEnum ConvertToInstallModeEnum(const std::string& in)
+ {
+ InstallModeEnum result = InstallModeEnum::Unknown;
+
+ if (Utility::CaseInsensitiveEquals(in, "interactive"))
+ {
+ result = InstallModeEnum::Interactive;
+ }
+ else if (Utility::CaseInsensitiveEquals(in, "silent"))
+ {
+ result = InstallModeEnum::Silent;
+ }
+ else if (Utility::CaseInsensitiveEquals(in, "silentWithProgress"))
+ {
+ result = InstallModeEnum::SilentWithProgress;
+ }
+
+ return result;
+ }
+
PlatformEnum ConvertToPlatformEnum(const std::string& in)
{
PlatformEnum result = PlatformEnum::Unknown;
diff --git a/src/AppInstallerCommonCore/Manifest/ManifestYamlPopulator.cpp b/src/AppInstallerCommonCore/Manifest/ManifestYamlPopulator.cpp
@@ -88,15 +88,15 @@ namespace AppInstaller::Manifest
return result;
}
- std::vector<ScopeEnum> ProcessScopeSequenceNode(const YAML::Node& node)
+ std::vector<InstallModeEnum> ProcessInstallModeSequenceNode(const YAML::Node& node)
{
THROW_HR_IF(E_INVALIDARG, !node.IsSequence());
- std::vector<ScopeEnum> result;
+ std::vector<InstallModeEnum> result;
for (auto const& entry : node.Sequence())
{
- result.emplace_back(ConvertToScopeEnum(entry.as<std::string>()));
+ result.emplace_back(ConvertToInstallModeEnum(entry.as<std::string>()));
}
return result;
@@ -221,7 +221,7 @@ namespace AppInstaller::Manifest
{ "Platform", [this](const YAML::Node& value)->ValidationErrors { m_p_installer->Platform = ProcessPlatformSequenceNode(value); return {}; } },
{ "MinimumOSVersion", [this](const YAML::Node& value)->ValidationErrors { m_p_installer->MinOSVersion = value.as<std::string>(); return {}; } },
{ "Scope", [this](const YAML::Node& value)->ValidationErrors { m_p_installer->Scope = ConvertToScopeEnum(value.as<std::string>()); return {}; } },
- { "InstallModes", [this](const YAML::Node& value)->ValidationErrors { m_p_installer->InstallModes = ProcessScopeSequenceNode(value); return {}; } },
+ { "InstallModes", [this](const YAML::Node& value)->ValidationErrors { m_p_installer->InstallModes = ProcessInstallModeSequenceNode(value); return {}; } },
{ "InstallerSwitches", [this](const YAML::Node& value)->ValidationErrors { m_p_switches = &(m_p_installer->Switches); return ValidateAndProcessFields(value, SwitchesFieldInfos); } },
{ "InstallerSuccessCodes", [this](const YAML::Node& value)->ValidationErrors { m_p_installer->InstallerSuccessCodes = ProcessInstallerSuccessCodeSequenceNode(value); return {}; } },
{ "UpgradeBehavior", [this](const YAML::Node& value)->ValidationErrors { m_p_installer->UpdateBehavior = ConvertToUpdateBehaviorEnum(value.as<std::string>()); return {}; } },
diff --git a/src/AppInstallerCommonCore/Public/winget/ManifestCommon.h b/src/AppInstallerCommonCore/Public/winget/ManifestCommon.h
@@ -75,7 +75,7 @@ namespace AppInstaller::Manifest
Language,
Log,
InstallLocation,
- Update
+ Update,
};
enum class ScopeEnum
@@ -85,6 +85,14 @@ namespace AppInstaller::Manifest
Machine,
};
+ enum class InstallModeEnum
+ {
+ Unknown,
+ Interactive,
+ Silent,
+ SilentWithProgress,
+ };
+
enum class PlatformEnum
{
Unknown,
@@ -100,7 +108,7 @@ namespace AppInstaller::Manifest
DefaultLocale,
Locale,
Merged,
- Preview
+ Preview,
};
struct PackageDependency
@@ -124,6 +132,8 @@ namespace AppInstaller::Manifest
ScopeEnum ConvertToScopeEnum(const std::string& in);
+ InstallModeEnum ConvertToInstallModeEnum(const std::string& in);
+
PlatformEnum ConvertToPlatformEnum(const std::string& in);
ManifestTypeEnum ConvertToManifestTypeEnum(const std::string& in);
diff --git a/src/AppInstallerCommonCore/Public/winget/ManifestInstaller.h b/src/AppInstallerCommonCore/Public/winget/ManifestInstaller.h
@@ -44,7 +44,7 @@ namespace AppInstaller::Manifest
ScopeEnum Scope = ScopeEnum::User;
- std::vector<ScopeEnum> InstallModes;
+ std::vector<InstallModeEnum> InstallModes;
// If present, has more precedence than root
std::map<InstallerSwitchType, string_t> Switches;