commit b82746e3533b8ee800247e40390995f3b44741d3 parent 2fff965eb8dec6f3bccffd866c249d91f9239013 Author: yao-msft <50888816+yao-msft@users.noreply.github.com> Date: Mon, 24 Jul 2023 11:32:43 -0700 Populate missing ManifestVersion for manifest from rest source and make PackageFamilyName and installer type manifest validation warning (#3460) Diffstat:
18 files changed, 61 insertions(+), 37 deletions(-)
diff --git a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj @@ -604,9 +604,6 @@ <CopyFileToFolders Include="TestData\Manifest-Good-DefaultExpectedReturnCodeInInstallerSuccessCodes.yaml"> <DeploymentContent>true</DeploymentContent> </CopyFileToFolders> - <CopyFileToFolders Include="TestData\Manifest-Good-PackageFamilyNameOnExe-Ver1_2.yaml"> - <DeploymentContent>true</DeploymentContent> - </CopyFileToFolders> <CopyFileToFolders Include="TestData\Manifest-Good-MultipleArpVersionDeclared.yaml"> <DeploymentContent>true</DeploymentContent> </CopyFileToFolders> diff --git a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters @@ -543,9 +543,6 @@ <CopyFileToFolders Include="TestData\Manifest-Good-NoArpVersionDeclared.yaml"> <Filter>TestData</Filter> </CopyFileToFolders> - <CopyFileToFolders Include="TestData\Manifest-Good-PackageFamilyNameOnExe-Ver1_2.yaml"> - <Filter>TestData</Filter> - </CopyFileToFolders> <CopyFileToFolders Include="TestData\Manifest-Good-SingleArpVersionDeclared.yaml"> <Filter>TestData</Filter> </CopyFileToFolders> diff --git a/src/AppInstallerCLITests/RestInterface_1_0.cpp b/src/AppInstallerCLITests/RestInterface_1_0.cpp @@ -453,6 +453,7 @@ TEST_CASE("GetManifests_GoodResponse", "[RestSource][Interface_1_0]") REQUIRE(manifest.Version == "3.0.0abc"); REQUIRE(manifest.Moniker == "FooBarMoniker"); REQUIRE(manifest.Channel == ""); + REQUIRE(manifest.ManifestVersion == AppInstaller::Manifest::ManifestVer{ "1.0.0" }); sampleManifest.VerifyLocalizations_AllFields(manifest); sampleManifest.VerifyInstallers_AllFields(manifest); } diff --git a/src/AppInstallerCLITests/RestInterface_1_1.cpp b/src/AppInstallerCLITests/RestInterface_1_1.cpp @@ -552,6 +552,7 @@ TEST_CASE("GetManifests_GoodResponse_V1_1", "[RestSource][Interface_1_1]") REQUIRE(manifest.Version == "3.0.0abc"); REQUIRE(manifest.Moniker == "FooBarMoniker"); REQUIRE(manifest.Channel == ""); + REQUIRE(manifest.ManifestVersion == AppInstaller::Manifest::ManifestVer{ "1.1.0" }); sampleManifest.VerifyLocalizations_AllFields(manifest); sampleManifest.VerifyInstallers_AllFields(manifest); } \ No newline at end of file diff --git a/src/AppInstallerCLITests/RestInterface_1_4.cpp b/src/AppInstallerCLITests/RestInterface_1_4.cpp @@ -371,6 +371,7 @@ TEST_CASE("GetManifests_GoodResponse_V1_4", "[RestSource][Interface_1_4]") REQUIRE(manifest.Version == "3.0.0abc"); REQUIRE(manifest.Moniker == "FooBarMoniker"); REQUIRE(manifest.Channel == ""); + REQUIRE(manifest.ManifestVersion == AppInstaller::Manifest::ManifestVer{ "1.4.0" }); sampleManifest.VerifyLocalizations_AllFields(manifest); sampleManifest.VerifyInstallers_AllFields(manifest); } diff --git a/src/AppInstallerCLITests/RestInterface_1_5.cpp b/src/AppInstallerCLITests/RestInterface_1_5.cpp @@ -397,6 +397,7 @@ TEST_CASE("GetManifests_GoodResponse_V1_5", "[RestSource][Interface_1_5]") REQUIRE(manifest.Version == "3.0.0abc"); REQUIRE(manifest.Moniker == "FooBarMoniker"); REQUIRE(manifest.Channel == ""); + REQUIRE(manifest.ManifestVersion == AppInstaller::Manifest::ManifestVer{ "1.5.0" }); sampleManifest.VerifyLocalizations_AllFields(manifest); sampleManifest.VerifyInstallers_AllFields(manifest); } diff --git a/src/AppInstallerCLITests/TestData/Manifest-Good-PackageFamilyNameOnExe-Ver1_2.yaml b/src/AppInstallerCLITests/TestData/Manifest-Good-PackageFamilyNameOnExe-Ver1_2.yaml @@ -1,24 +0,0 @@ -PackageIdentifier: Microsoft.WinAppSdk -Publisher: Microsoft -PackageName: WinAppSdk -PackageVersion: 1.0 -License: Microsoft Software License -MinimumOSVersion: 10.0.17763.0 -Tags: -- WinAppSdk -ShortDescription: WinAppSdk -PackageUrl: https://github.com/microsoft/WindowsAppSDK -Installers: -- Architecture: x86 - InstallerType: exe - InstallerUrl: https://ThisIsTest.com/TestIndex/installer/WindowsAppRuntimeInstall.exe - InstallerSha256: b565f45da868b637686d4c098e9e4c3e16424cff1ed2f19d5665602fdd8dfba6 - PackageFamilyName: MicrosoftCorporationII.WindowsAppRuntime.Main.1.0_8wekyb3d8bbwe - AppsAndFeaturesEntries: - - InstallerType: msix - InstallerSwitches: - Silent: /s - SilentWithProgress: /s -PackageLocale: en-US -ManifestType: singleton -ManifestVersion: 1.2.0 diff --git a/src/AppInstallerCLITests/YamlManifest.cpp b/src/AppInstallerCLITests/YamlManifest.cpp @@ -239,7 +239,6 @@ TEST_CASE("ReadGoodManifests", "[ManifestValidation]") { "Manifest-Good-Minimum-InstallerType.yaml" }, { "Manifest-Good-Switches.yaml" }, { "Manifest-Good-DefaultExpectedReturnCodeInInstallerSuccessCodes.yaml" }, - { "Manifest-Good-PackageFamilyNameOnExe-Ver1_2.yaml" }, }; for (auto const& testCase : TestCases) @@ -300,9 +299,9 @@ TEST_CASE("ReadBadManifests", "[ManifestValidation]") { "Manifest-Bad-VersionMissing.yaml", "Missing required property 'Version'" }, { "Manifest-Bad-InvalidManifestVersionValue.yaml", "Failed to validate against schema associated with property name 'ManifestVersion'" }, { "InstallFlowTest_MSStore.yaml", "Field value is not supported. [InstallerType] Value: msstore" }, - { "Manifest-Bad-PackageFamilyNameOnMSI.yaml", "The specified installer type does not support PackageFamilyName. [InstallerType] Value: msi" }, + { "Manifest-Bad-PackageFamilyNameOnMSI.yaml", "The specified installer type does not support PackageFamilyName. [InstallerType] Value: msi", true }, { "Manifest-Bad-ProductCodeOnMSIX.yaml", "The specified installer type does not support ProductCode. [InstallerType] Value: msix" }, - { "Manifest-Bad-InvalidUpdateBehavior.yaml", "Invalid field value. [UpdateBehavior]" }, + { "Manifest-Bad-InvalidUpdateBehavior.yaml", "Invalid field value. [UpgradeBehavior]" }, { "Manifest-Bad-InvalidLocale.yaml", "The locale value is not a well formed bcp47 language tag." }, { "Manifest-Bad-AppsAndFeaturesEntriesOnMSIX.yaml", "The specified installer type does not write to Apps and Features entry." }, { "InstallFlowTest_LicenseAgreement.yaml", "Field usage requires verified publishers.", true }, diff --git a/src/AppInstallerCommonCore/Manifest/ManifestValidation.cpp b/src/AppInstallerCommonCore/Manifest/ManifestValidation.cpp @@ -166,14 +166,14 @@ namespace AppInstaller::Manifest if (installer.UpdateBehavior == UpdateBehaviorEnum::Unknown) { - resultErrors.emplace_back(ManifestError::InvalidFieldValue, "UpdateBehavior"); + resultErrors.emplace_back(ManifestError::InvalidFieldValue, "UpgradeBehavior"); } // Validate system reference strings if they are set at the installer level - // Allow PackageFamilyName to be declared with non msix installers to support nested installer scenarios after manifest version 1.1 - if (manifest.ManifestVersion <= ManifestVer{ s_ManifestVersionV1_1 } && !installer.PackageFamilyName.empty() && !DoesInstallerTypeUsePackageFamilyName(installer.EffectiveInstallerType())) + // Allow PackageFamilyName to be declared with non msix installers to support nested installer scenarios. But still report as warning to notify user of this uncommon case. + if (!installer.PackageFamilyName.empty() && !DoesInstallerTypeUsePackageFamilyName(installer.EffectiveInstallerType())) { - resultErrors.emplace_back(ManifestError::InstallerTypeDoesNotSupportPackageFamilyName, "InstallerType", InstallerTypeToString(installer.EffectiveInstallerType())); + resultErrors.emplace_back(ManifestError::InstallerTypeDoesNotSupportPackageFamilyName, "InstallerType", std::string{ InstallerTypeToString(installer.EffectiveInstallerType()) }, ValidationError::Level::Warning); } if (!installer.ProductCode.empty() && !DoesInstallerTypeUseProductCode(installer.EffectiveInstallerType())) diff --git a/src/AppInstallerRepositoryCore/AppInstallerRepositoryCore.vcxproj.filters b/src/AppInstallerRepositoryCore/AppInstallerRepositoryCore.vcxproj.filters @@ -76,6 +76,12 @@ <Filter Include="Rest\Schema\1_4\Json"> <UniqueIdentifier>{d9d70cf5-ce04-4db2-a0ec-970dd0ad22b6}</UniqueIdentifier> </Filter> + <Filter Include="Rest\Schema\1_5"> + <UniqueIdentifier>{f131c993-1136-4f4c-85a9-8606c6d297a8}</UniqueIdentifier> + </Filter> + <Filter Include="Rest\Schema\1_5\Json"> + <UniqueIdentifier>{78cf34a8-b868-4393-ad9c-630940569186}</UniqueIdentifier> + </Filter> <Filter Include="Microsoft\Schema\Pinning_1_0"> <UniqueIdentifier>{f05e19bb-2161-4ab0-9d04-2dfa2d3eb3c6}</UniqueIdentifier> </Filter> @@ -336,6 +342,12 @@ <ClInclude Include="Rest\Schema\1_4\Json\SearchResponseDeserializer.h"> <Filter>Rest\Schema\1_4\Json</Filter> </ClInclude> + <ClInclude Include="Rest\Schema\1_5\Json\ManifestDeserializer.h"> + <Filter>Rest\Schema\1_5\Json</Filter> + </ClInclude> + <ClInclude Include="Rest\Schema\1_5\Interface.h"> + <Filter>Rest\Schema\1_5</Filter> + </ClInclude> <ClInclude Include="Rest\Schema\SearchRequestComposer.h"> <Filter>Rest\Schema</Filter> </ClInclude> @@ -554,6 +566,12 @@ <ClCompile Include="Rest\Schema\1_4\Json\SearchResponseDeserializer_1_4.cpp"> <Filter>Rest\Schema\1_4\Json</Filter> </ClCompile> + <ClCompile Include="Rest\Schema\1_5\Json\ManifestDeserializer_1_5.cpp"> + <Filter>Rest\Schema\1_5\Json</Filter> + </ClCompile> + <ClCompile Include="Rest\Schema\1_5\RestInterface_1_5.cpp"> + <Filter>Rest\Schema\1_5</Filter> + </ClCompile> <ClCompile Include="Rest\Schema\SearchRequestComposer.cpp"> <Filter>Rest\Schema</Filter> </ClCompile> diff --git a/src/AppInstallerRepositoryCore/Rest/Schema/1_0/Json/ManifestDeserializer.h b/src/AppInstallerRepositoryCore/Rest/Schema/1_0/Json/ManifestDeserializer.h @@ -45,5 +45,7 @@ namespace AppInstaller::Repository::Rest::Schema::V1_0::Json virtual Manifest::InstallerTypeEnum ConvertToInstallerType(std::string_view in) const; std::vector<Manifest::string_t> ConvertToManifestStringArray(const std::vector<std::string>& values) const; + + virtual Manifest::ManifestVer GetManifestVersion() const; }; } diff --git a/src/AppInstallerRepositoryCore/Rest/Schema/1_0/Json/ManifestDeserializer_1_0.cpp b/src/AppInstallerRepositoryCore/Rest/Schema/1_0/Json/ManifestDeserializer_1_0.cpp @@ -160,6 +160,9 @@ namespace AppInstaller::Repository::Rest::Schema::V1_0::Json for (auto& versionItem : versions.value().get()) { Manifest::Manifest manifest; + + manifest.ManifestVersion = GetManifestVersion(); + manifest.Id = id.value(); std::optional<std::string> packageVersion = JSON::GetRawStringValueFromJsonNode(versionItem, JSON::GetUtilityString(PackageVersion)); @@ -525,4 +528,9 @@ namespace AppInstaller::Repository::Rest::Schema::V1_0::Json return result; } + + Manifest::ManifestVer ManifestDeserializer::GetManifestVersion() const + { + return Manifest::s_ManifestVersionV1; + } } diff --git a/src/AppInstallerRepositoryCore/Rest/Schema/1_1/Json/ManifestDeserializer.h b/src/AppInstallerRepositoryCore/Rest/Schema/1_1/Json/ManifestDeserializer.h @@ -20,5 +20,7 @@ namespace AppInstaller::Repository::Rest::Schema::V1_1::Json virtual Manifest::ExpectedReturnCodeEnum ConvertToExpectedReturnCodeEnum(std::string_view in) const; virtual Manifest::ManifestInstaller::ExpectedReturnCodeInfo DeserializeExpectedReturnCodeInfo(const web::json::value& expectedReturnCodeJsonObject) const; + + Manifest::ManifestVer GetManifestVersion() const override; }; } diff --git a/src/AppInstallerRepositoryCore/Rest/Schema/1_1/Json/ManifestDeserializer_1_1.cpp b/src/AppInstallerRepositoryCore/Rest/Schema/1_1/Json/ManifestDeserializer_1_1.cpp @@ -287,4 +287,9 @@ namespace AppInstaller::Repository::Rest::Schema::V1_1::Json return result; } + + Manifest::ManifestVer ManifestDeserializer::GetManifestVersion() const + { + return Manifest::s_ManifestVersionV1_1; + } } diff --git a/src/AppInstallerRepositoryCore/Rest/Schema/1_4/Json/ManifestDeserializer.h b/src/AppInstallerRepositoryCore/Rest/Schema/1_4/Json/ManifestDeserializer.h @@ -20,5 +20,7 @@ namespace AppInstaller::Repository::Rest::Schema::V1_4::Json Manifest::ExpectedReturnCodeEnum ConvertToExpectedReturnCodeEnum(std::string_view in) const override; Manifest::ManifestInstaller::ExpectedReturnCodeInfo DeserializeExpectedReturnCodeInfo(const web::json::value& expectedReturnCodeJsonObject) const override; + + Manifest::ManifestVer GetManifestVersion() const override; }; } diff --git a/src/AppInstallerRepositoryCore/Rest/Schema/1_4/Json/ManifestDeserializer_1_4.cpp b/src/AppInstallerRepositoryCore/Rest/Schema/1_4/Json/ManifestDeserializer_1_4.cpp @@ -225,4 +225,9 @@ namespace AppInstaller::Repository::Rest::Schema::V1_4::Json return result; } + + Manifest::ManifestVer ManifestDeserializer::GetManifestVersion() const + { + return Manifest::s_ManifestVersionV1_4; + } } diff --git a/src/AppInstallerRepositoryCore/Rest/Schema/1_5/Json/ManifestDeserializer.h b/src/AppInstallerRepositoryCore/Rest/Schema/1_5/Json/ManifestDeserializer.h @@ -9,5 +9,9 @@ namespace AppInstaller::Repository::Rest::Schema::V1_5::Json struct ManifestDeserializer : public V1_4::Json::ManifestDeserializer { std::optional<Manifest::ManifestLocalization> DeserializeLocale(const web::json::value& localeJsonObject) const override; + + protected: + + Manifest::ManifestVer GetManifestVersion() const override; }; } diff --git a/src/AppInstallerRepositoryCore/Rest/Schema/1_5/Json/ManifestDeserializer_1_5.cpp b/src/AppInstallerRepositoryCore/Rest/Schema/1_5/Json/ManifestDeserializer_1_5.cpp @@ -70,4 +70,9 @@ namespace AppInstaller::Repository::Rest::Schema::V1_5::Json return result; } + + Manifest::ManifestVer ManifestDeserializer::GetManifestVersion() const + { + return Manifest::s_ManifestVersionV1_5; + } }