Skip to content

Commit

Permalink
ProductId and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yao-msft committed Nov 1, 2024
1 parent f80b3a5 commit 08dbfd0
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 27 deletions.
14 changes: 14 additions & 0 deletions src/AppInstallerCLITests/YamlManifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,20 @@ TEST_CASE("WriteManifestWithMultipleLocale", "[ManifestCreation]")
REQUIRE(generatedManifest.Localizations.size() == 2);
}

TEST_CASE("WriteManifestWithMSStoreInstaller", "[ManifestCreation]")
{
Manifest msstoreManifest = YamlParser::CreateFromPath(TestDataFile("DownloadFlowTest_MSStore.yaml"));
TempDirectory exportedDirectory{ "exported" };
std::filesystem::path generatedManifestPath = exportedDirectory.GetPath() / "testManifestWithMultipleLocale.yaml";
msstoreManifest.ManifestVersion = ManifestVer{ "1.1.0" };
YamlWriter::OutputYamlFile(msstoreManifest, msstoreManifest.Installers[0], generatedManifestPath);

REQUIRE(std::filesystem::exists(generatedManifestPath));
Manifest generatedManifest = YamlParser::CreateFromPath(generatedManifestPath);
REQUIRE(generatedManifest.Installers[0].BaseInstallerType == InstallerTypeEnum::MSStore);
REQUIRE(!generatedManifest.Installers[0].ProductId.empty());
}

YamlManifestInfo CreateYamlManifestInfo(std::string testDataFile)
{
YamlManifestInfo result;
Expand Down
2 changes: 2 additions & 0 deletions src/AppInstallerCommonCore/Manifest/ManifestYamlPopulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ namespace AppInstaller::Manifest
{ "InstallerUrl", [](const YAML::Node& value, const VariantManifestPtr& v)->ValidationErrors { variant_ptr<ManifestInstaller>(v)->Url = value.as<std::string>(); return {}; } },
{ "InstallerSha256", [](const YAML::Node& value, const VariantManifestPtr& v)->ValidationErrors { variant_ptr<ManifestInstaller>(v)->Sha256 = Utility::SHA256::ConvertToBytes(value.as<std::string>()); return {}; } },
{ "SignatureSha256", [](const YAML::Node& value, const VariantManifestPtr& v)->ValidationErrors { variant_ptr<ManifestInstaller>(v)->SignatureSha256 = Utility::SHA256::ConvertToBytes(value.as<std::string>()); return {}; } },
// No custom validation needed at field populating time since we have semantic validation later to block msstore and productId from community repo.
{ "MSStoreProductIdentifier", [](const YAML::Node& value, const VariantManifestPtr& v)->ValidationErrors { variant_ptr<ManifestInstaller>(v)->ProductId = value.as<std::string>(); return {}; } },
};

std::move(v1InstallerFields.begin(), v1InstallerFields.end(), std::inserter(result, result.end()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ private void ValidateManifestFields(Manifest manifest, TestManifestVersion manif
if (manifestVersion >= TestManifestVersion.V190)
{
Assert.False(installer1.ArchiveBinariesDependOnPath);
Assert.Equal("fakeIdentifier", installer2.ProductId);
}

// Additional Localizations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ Installers:
InstallerSha256: 69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82
InstallerUrl: https://www.microsoft.com/msixsdk/msixsdkx64.exe
InstallerType: exe
ProductCode: '{Bar}'
ProductCode: '{Bar}'
MSStoreProductIdentifier: fakeIdentifier
ManifestType: merged
ManifestVersion: 1.7.0
ManifestVersion: 1.7.0
36 changes: 18 additions & 18 deletions src/WinGetUtilInterop/Manifest/V1/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,17 @@ public class Manifest
/// <summary>
/// Gets or sets a value indicating whether the default installer behavior aborts terminal.
/// </summary>
public bool InstallerAbortsTerminal { get; set; }
public bool? InstallerAbortsTerminal { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the default installer behavior requires explicit install location.
/// </summary>
public bool InstallLocationRequired { get; set; }
public bool? InstallLocationRequired { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the default installer behavior requires explicit upgrade.
/// </summary>
public bool RequireExplicitUpgrade { get; set; }
public bool? RequireExplicitUpgrade { get; set; }

/// <summary>
/// Gets or sets the default installer release date.
Expand All @@ -303,7 +303,7 @@ public class Manifest
/// <summary>
/// Gets or sets a value indicating whether to display install warnings.
/// </summary>
public bool DisplayInstallWarnings { get; set; }
public bool? DisplayInstallWarnings { get; set; }

/// <summary>
/// Gets or sets the default list of apps and features entries.
Expand All @@ -318,33 +318,33 @@ public class Manifest
/// <summary>
/// Gets or sets the default list of installer expected return codes.
/// </summary>
public List<InstallerExpectedReturnCode> ExpectedReturnCodes { get; set; }

/// <summary>
/// Gets or sets collection of ManifestInstaller. At least one is required.
/// </summary>
public List<ManifestInstaller> Installers { get; set; }

/// <summary>
/// Gets or sets collection of additional ManifestLocalization.
/// </summary>
public List<ManifestLocalization> Localization { get; set; }

public List<InstallerExpectedReturnCode> ExpectedReturnCodes { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the installer is prohibited from being downloaded for offline installation.
/// </summary>
public bool DownloadCommandProhibited { get; set; }
public bool? DownloadCommandProhibited { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the install location should be added directly to the PATH environment variable.
/// </summary>
public bool ArchiveBinariesDependOnPath { get; set; }
public bool? ArchiveBinariesDependOnPath { get; set; }

/// <summary>
/// Gets or sets the default repair behavior.
/// </summary>
public string RepairBehavior { get; set; }

/// <summary>
/// Gets or sets collection of ManifestInstaller. At least one is required.
/// </summary>
public List<ManifestInstaller> Installers { get; set; }

/// <summary>
/// Gets or sets collection of additional ManifestLocalization.
/// </summary>
public List<ManifestLocalization> Localization { get; set; }

/// <summary>
/// Deserialize a stream reader into a Manifest object.
/// </summary>
Expand Down
22 changes: 15 additions & 7 deletions src/WinGetUtilInterop/Manifest/V1/ManifestInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ public class ManifestInstaller
/// <summary>
/// Gets or sets the signature SHA256 for an appx/msix. Only used by appx/msix type.
/// </summary>
public string SignatureSha256 { get; set; }
public string SignatureSha256 { get; set; }

/// <summary>
/// Gets or sets the Store ProductId. Only used when InstallerType is MSStore.
/// </summary>
[YamlMember(Alias = "MSStoreProductIdentifier")]
public string ProductId { get; set; }

// Common installer fields that may have defaults in manifest root level.

/// <summary>
/// Gets or sets the installer locale.
Expand Down Expand Up @@ -131,17 +139,17 @@ public class ManifestInstaller
/// <summary>
/// Gets or sets a value indicating whether the installer behavior aborts terminal.
/// </summary>
public bool InstallerAbortsTerminal { get; set; }
public bool? InstallerAbortsTerminal { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the installer behavior requires explicit install location.
/// </summary>
public bool InstallLocationRequired { get; set; }
public bool? InstallLocationRequired { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the installer behavior requires explicit upgrade.
/// </summary>
public bool RequireExplicitUpgrade { get; set; }
public bool? RequireExplicitUpgrade { get; set; }

/// <summary>
/// Gets or sets the installer release date.
Expand Down Expand Up @@ -191,17 +199,17 @@ public class ManifestInstaller
/// <summary>
/// Gets or sets a value indicating whether to display install warnings.
/// </summary>
public bool DisplayInstallWarnings { get; set; }
public bool? DisplayInstallWarnings { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the installer is prohibited from being downloaded for offline installation.
/// </summary>
public bool DownloadCommandProhibited { get; set; }
public bool? DownloadCommandProhibited { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the install location should be added directly to the PATH environment variable.
/// </summary>
public bool ArchiveBinariesDependOnPath { get; set; }
public bool? ArchiveBinariesDependOnPath { get; set; }

/// <summary>
/// Gets or sets the repair behavior.
Expand Down

0 comments on commit 08dbfd0

Please sign in to comment.