From d2eae39d844e52093bc01b6fdbee21e096a65dd4 Mon Sep 17 00:00:00 2001 From: Yao Sun Date: Thu, 20 Jun 2024 15:33:28 -0700 Subject: [PATCH] Fix export manifest with multiple locales --- src/AppInstallerCLITests/YamlManifest.cpp | 12 ++++++++++++ src/AppInstallerCommonCore/Manifest/YamlWriter.cpp | 10 +++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/AppInstallerCLITests/YamlManifest.cpp b/src/AppInstallerCLITests/YamlManifest.cpp index 3938d20724..b7c1517b72 100644 --- a/src/AppInstallerCLITests/YamlManifest.cpp +++ b/src/AppInstallerCLITests/YamlManifest.cpp @@ -1289,6 +1289,18 @@ TEST_CASE("WriteV1_7SingletonManifestAndVerifyContents", "[ManifestCreation]") VerifyV1ManifestContent(generatedMultiFileManifest, false, ManifestVer{ s_ManifestVersionV1_7 }, true); } +TEST_CASE("WriteManifestWithMultipleLocale", "[ManifestCreation]") +{ + Manifest multiLocaleManifest = YamlParser::CreateFromPath(TestDataFile("Manifest-Good-MultiLocale.yaml")); + TempDirectory exportedDirectory{ "exported" }; + std::filesystem::path generatedManifestPath = exportedDirectory.GetPath() / "testManifestWithMultipleLocale.yaml"; + YamlWriter::OutputYamlFile(multiLocaleManifest, multiLocaleManifest.Installers[0], generatedManifestPath); + + REQUIRE(std::filesystem::exists(generatedManifestPath)); + Manifest generatedManifest = YamlParser::CreateFromPath(generatedManifestPath); + REQUIRE(generatedManifest.Localizations.size() == 2); +} + YamlManifestInfo CreateYamlManifestInfo(std::string testDataFile) { YamlManifestInfo result; diff --git a/src/AppInstallerCommonCore/Manifest/YamlWriter.cpp b/src/AppInstallerCommonCore/Manifest/YamlWriter.cpp index 33d35249a4..61910e13e9 100644 --- a/src/AppInstallerCommonCore/Manifest/YamlWriter.cpp +++ b/src/AppInstallerCommonCore/Manifest/YamlWriter.cpp @@ -610,14 +610,14 @@ namespace AppInstaller::Manifest::YamlWriter { out << YAML::Key << Localization; out << YAML::BeginSeq; - out << YAML::BeginMap; for (const auto& localization : localizations) - { - ProcessLocaleFields(out, localization); + { + out << YAML::BeginMap; + ProcessLocaleFields(out, localization); + out << YAML::EndMap; } - out << YAML::EndMap; out << YAML::EndSeq; } } @@ -669,4 +669,4 @@ namespace AppInstaller::Manifest::YamlWriter emitter.Emit(outFileStream); outFileStream.close(); } -} \ No newline at end of file +}