Skip to content

Commit

Permalink
Add 1.7 manifest fields to WingetUtilsInterop (#4157)
Browse files Browse the repository at this point in the history
  • Loading branch information
yao-msft authored Feb 9, 2024
1 parent 4d51b5f commit 92f9ac3
Show file tree
Hide file tree
Showing 7 changed files with 397 additions and 70 deletions.
169 changes: 110 additions & 59 deletions src/WinGetUtilInterop.UnitTests/ManifestUnitTest/V1ManifestReadTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ private enum TestManifestVersion
V100,
V110,
V160,
V170,
}

/// <summary>
Expand All @@ -57,6 +58,11 @@ public void ReadV1ManifestsAndVerifyContents()
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestCollateral", ManifestStrings.V160ManifestMerged));

this.ValidateManifestFields(v160manifest, TestManifestVersion.V160);

Manifest v170manifest = Manifest.CreateManifestFromPath(
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestCollateral", ManifestStrings.V170ManifestMerged));

this.ValidateManifestFields(v170manifest, TestManifestVersion.V170);
}

/// <summary>
Expand Down Expand Up @@ -126,6 +132,27 @@ private void ValidateManifestFields(Manifest manifest, TestManifestVersion manif
Assert.Equal("https://DefaultAgreementUrl.net", manifest.Agreements[0].AgreementUrl);
}

if (manifestVersion >= TestManifestVersion.V160)
{
Assert.Equal("Default installation notes", manifest.InstallationNotes);
Assert.Equal("https://DefaultPurchaseUrl.com", manifest.PurchaseUrl);

Assert.Single(manifest.Documentations);
ManifestDocumentation manifestDocumentation = manifest.Documentations[0];

Assert.Equal("Default document label", manifestDocumentation.DocumentLabel);
Assert.Equal("https://DefaultDocumentUrl.com", manifestDocumentation.DocumentUrl);

Assert.Single(manifest.Icons);
ManifestIcon icon = manifest.Icons[0];

Assert.Equal("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8123", icon.IconSha256);
Assert.Equal("default", icon.IconTheme);
Assert.Equal("https://testIcon", icon.IconUrl);
Assert.Equal("custom", icon.IconResolution);
Assert.Equal("ico", icon.IconFileType);
}

// Default installer
Assert.Equal("en-US", manifest.InstallerLocale);
Assert.Equal(2, manifest.Platform.Count);
Expand Down Expand Up @@ -205,6 +232,41 @@ private void ValidateManifestFields(Manifest manifest, TestManifestVersion manif
Assert.Equal("contactSupport", manifest.ExpectedReturnCodes[0].ReturnResponse);
}

if (manifestVersion >= TestManifestVersion.V160)
{
Assert.Equal("msi", manifest.NestedInstallerType);
Assert.Single(manifest.NestedInstallerFiles);
InstallerNestedInstallerFile installerNestedInstallerFile = manifest.NestedInstallerFiles[0];
Assert.Equal("RelativeFilePath", installerNestedInstallerFile.RelativeFilePath);
Assert.Equal("PortableCommandAlias", installerNestedInstallerFile.PortableCommandAlias);

InstallerInstallationMetadata installerInstallationMetadata = manifest.InstallationMetadata;
Assert.Equal("%ProgramFiles%\\TestApp", installerInstallationMetadata.DefaultInstallLocation);
Assert.Single(installerInstallationMetadata.Files);

ManifestInstallerFile installerFile = installerInstallationMetadata.Files[0];
Assert.Equal("main.exe", installerFile.RelativeFilePath);
Assert.Equal("DisplayName", installerFile.DisplayName);
Assert.Equal("/arg", installerFile.InvocationParameter);
Assert.Equal("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82", installerFile.FileSha256);

Assert.Single(manifest.UnsupportedArguments);
Assert.Equal("log", manifest.UnsupportedArguments[0]);

Assert.Single(manifest.UnsupportedOSArchitectures);
Assert.Equal("arm", manifest.UnsupportedOSArchitectures[0]);

Assert.True(manifest.DisplayInstallWarnings);
Assert.True(manifest.DownloadCommandProhibited);
}

if (manifestVersion >= TestManifestVersion.V170)
{
Assert.Equal("/repair", defaultSwitches.Repair);
Assert.Equal("uninstaller", manifest.RepairBehavior);
}

// Individual installers
Assert.Equal(2, manifest.Installers.Count);
ManifestInstaller installer1 = manifest.Installers[0];
Assert.Equal("x86", installer1.Arch);
Expand Down Expand Up @@ -280,7 +342,35 @@ private void ValidateManifestFields(Manifest manifest, TestManifestVersion manif
Assert.Equal("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82", installer2.Sha256);
Assert.Equal("{Bar}", installer2.ProductCode);

// Localization
if (manifestVersion >= TestManifestVersion.V160)
{
Assert.Single(installer1.InstallationMetadata.Files);
ManifestInstallerFile installerFile2 = installer1.InstallationMetadata.Files[0];
Assert.Equal("main2.exe", installerFile2.RelativeFilePath);
Assert.Equal("DisplayName2", installerFile2.DisplayName);
Assert.Equal("/arg2", installerFile2.InvocationParameter);
Assert.Equal("79D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82", installerFile2.FileSha256);

Assert.Equal("msi", installer1.NestedInstallerType);

InstallerNestedInstallerFile installerNestedInstallerFile2 = installer1.NestedInstallerFiles[0];
Assert.Equal("RelativeFilePath2", installerNestedInstallerFile2.RelativeFilePath);
Assert.Equal("PortableCommandAlias2", installerNestedInstallerFile2.PortableCommandAlias);

Assert.Single(installer1.UnsupportedArguments);
Assert.Equal("location", installer1.UnsupportedArguments[0]);

Assert.True(installer1.DisplayInstallWarnings);
Assert.True(installer1.DownloadCommandProhibited);
}

if (manifestVersion >= TestManifestVersion.V170)
{
Assert.Equal("/r", installer1Switches.Repair);
Assert.Equal("modify", installer1.RepairBehavior);
}

// Additional Localizations
Assert.Single(manifest.Localization);
ManifestLocalization localization1 = manifest.Localization[0];
Assert.Equal("en-GB", localization1.PackageLocale);
Expand Down Expand Up @@ -313,67 +403,23 @@ private void ValidateManifestFields(Manifest manifest, TestManifestVersion manif

if (manifestVersion >= TestManifestVersion.V160)
{
Assert.Equal("msi", manifest.NestedInstallerType);
Assert.Equal("Default installation notes", manifest.InstallationNotes);
Assert.Equal("https://DefaultPurchaseUrl.com", manifest.PurchaseUrl);

Assert.True(manifest.DisplayInstallWarnings);
Assert.True(manifest.DownloadCommandProhibited);

Assert.Single(manifest.NestedInstallerFiles);
InstallerNestedInstallerFile installerNestedInstallerFile = manifest.NestedInstallerFiles[0];
Assert.Equal("RelativeFilePath", installerNestedInstallerFile.RelativeFilePath);
Assert.Equal("PortableCommandAlias", installerNestedInstallerFile.PortableCommandAlias);

InstallerInstallationMetadata installerInstallationMetadata = manifest.InstallationMetadata;
Assert.Equal("%ProgramFiles%\\TestApp", installerInstallationMetadata.DefaultInstallLocation);
Assert.Single(installerInstallationMetadata.Files);

ManifestInstallerFile installerFile = installerInstallationMetadata.Files[0];
Assert.Equal("main.exe", installerFile.RelativeFilePath);
Assert.Equal("DisplayName", installerFile.DisplayName);
Assert.Equal("/arg", installerFile.InvocationParameter);
Assert.Equal("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82", installerFile.FileSha256);

Assert.Single(manifest.Documentations);
ManifestDocumentation manifestDocumentation = manifest.Documentations[0];

Assert.Equal("Default document label", manifestDocumentation.DocumentLabel);
Assert.Equal("https://DefaultDocumentUrl.com", manifestDocumentation.DocumentUrl);
Assert.Equal("Installation notes", localization1.InstallationNotes);
Assert.Equal("https://PurchaseUrl.com", localization1.PurchaseUrl);

Assert.Single(manifest.Icons);
ManifestIcon icon = manifest.Icons[0];

Assert.Equal("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8123", icon.IconSha256);
Assert.Equal("default", icon.IconTheme);
Assert.Equal("https://testIcon", icon.IconUrl);
Assert.Equal("custom", icon.IconResolution);
Assert.Equal("ico", icon.IconFileType);
Assert.Single(localization1.Documentations);
ManifestDocumentation manifestDocumentation = localization1.Documentations[0];

Assert.Single(manifest.UnsupportedArguments);
Assert.Equal("log", manifest.UnsupportedArguments[0]);
Assert.Equal("Document label", manifestDocumentation.DocumentLabel);
Assert.Equal("https://DocumentUrl.com", manifestDocumentation.DocumentUrl);

Assert.Single(manifest.UnsupportedOSArchitectures);
Assert.Equal("arm", manifest.UnsupportedOSArchitectures[0]);
Assert.Single(localization1.Icons);
ManifestIcon icon = localization1.Icons[0];

Assert.Single(installer1.InstallationMetadata.Files);
ManifestInstallerFile installerFile2 = installer1.InstallationMetadata.Files[0];
Assert.Equal("main2.exe", installerFile2.RelativeFilePath);
Assert.Equal("DisplayName2", installerFile2.DisplayName);
Assert.Equal("/arg2", installerFile2.InvocationParameter);
Assert.Equal("79D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82", installerFile2.FileSha256);

Assert.Equal("msi", installer1.NestedInstallerType);

InstallerNestedInstallerFile installerNestedInstallerFile2 = installer1.NestedInstallerFiles[0];
Assert.Equal("RelativeFilePath2", installerNestedInstallerFile2.RelativeFilePath);
Assert.Equal("PortableCommandAlias2", installerNestedInstallerFile2.PortableCommandAlias);

Assert.Single(installer1.UnsupportedArguments);
Assert.Equal("location", installer1.UnsupportedArguments[0]);

Assert.True(installer1.DisplayInstallWarnings);
Assert.True(installer1.DownloadCommandProhibited);
Assert.Equal("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8321", icon.IconSha256);
Assert.Equal("dark", icon.IconTheme);
Assert.Equal("https://testIcon2", icon.IconUrl);
Assert.Equal("32x32", icon.IconResolution);
Assert.Equal("png", icon.IconFileType);
}
}

Expand All @@ -393,10 +439,15 @@ internal class ManifestStrings
public const string V110ManifestMerged = "V1_1ManifestMerged.yaml";

/// <summary>
/// Merged v1.1 manifest.
/// Merged v1.6 manifest.
/// </summary>
public const string V160ManifestMerged = "V1_6ManifestMerged.yaml";

/// <summary>
/// Merged v1.7 manifest.
/// </summary>
public const string V170ManifestMerged = "V1_7ManifestMerged.yaml";

/// <summary>
/// Merged v1 manifest without localization.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ Localization:
Tags:
- appxsdkUK
- msixsdkUK
PurchaseUrl: https://PurchaseUrl.com
InstallationNotes: Installation notes
Documentations:
- DocumentLabel: Document label
DocumentUrl: https://DocumentUrl.com
Icons:
- IconUrl: https://testIcon2
IconFileType: png
IconResolution: 32x32
IconTheme: dark
IconSha256: 69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8321
Installers:
- Architecture: x86
InstallerLocale: en-GB
Expand Down Expand Up @@ -230,5 +241,5 @@ Installers:
InstallerUrl: https://www.microsoft.com/msixsdk/msixsdkx64.exe
InstallerType: exe
ProductCode: '{Bar}'
ManifestType: singleton
ManifestType: merged
ManifestVersion: 1.6.0
Loading

0 comments on commit 92f9ac3

Please sign in to comment.