Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add InstallationMetadata to manifests for future deep installation detection #2350

Merged
merged 5 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions schemas/JSON/manifests/v1.2.0/manifest.singleton.1.2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@
"RequireExplicitUpgrade": {
"$ref": "#/definitions/RequireExplicitUpgrade"
},
"DisplayInstallWarnings": {
"$ref": "#/definitions/DisplayInstallWarnings"
},
"UnsupportedOSArchitectures": {
"$ref": "#/definitions/UnsupportedOSArchitectures"
},
Expand Down Expand Up @@ -822,6 +825,9 @@
"RequireExplicitUpgrade": {
"$ref": "#/definitions/RequireExplicitUpgrade"
},
"DisplayInstallWarnings": {
"$ref": "#/definitions/DisplayInstallWarnings"
},
"UnsupportedOSArchitectures": {
"$ref": "#/definitions/UnsupportedOSArchitectures"
},
Expand Down
63 changes: 61 additions & 2 deletions schemas/JSON/manifests/v1.3.0/manifest.installer.1.3.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"description": "The command alias to be used for calling the package. Only applies to the nested portable package"
}
},
"required": [ "RelativeFilePath" ],
"description": "A nested installer file contained inside an archive"
},
"maxItems": 1024,
Expand Down Expand Up @@ -513,6 +514,58 @@
],
"description": "The installer's elevation requirement"
},
"InstallationMetadata": {
"type": "object",
"title": "InstallationMetadata",
"properties": {
"DefaultInstallLocation": {
"type": [ "string", "null" ],
"minLength": 1,
"maxLength": 2048,
"description": "Represents the default installed package location. Used for deeper installation detection."
},
"Files": {
"type": [ "array", "null" ],
"uniqueItems": true,
"items": {
"type": "object",
"title": "InstalledFile",
"properties": {
"RelativeFilePath": {
"type": "string",
"minLength": 1,
"maxLength": 2048,
"description": "The relative path to the installed file."
},
"FileSha256": {
"type": [ "string", "null" ],
"pattern": "^[A-Fa-f0-9]{64}$",
"description": "Optional Sha256 of the installed file."
},
"FileType": {
"type": [ "string", "null" ],
"enum": [
"launch",
"uninstall",
"other"
],
"description": "The optional installed file type. If not specified, the file is treated as other."
},
"InvocationParameter": {
"type": "string",
"minLength": 1,
"maxLength": 2048,
"description": "Optional parameter for invocable files."
}
},
"required": [ "RelativeFilePath" ],
"description": "Represents an installed file."
},
"description": "List of installed files."
}
},
"description": "Details about the installation. Used for deeper installation detection."
},
"Installer": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -624,6 +677,9 @@
},
"ElevationRequirement": {
"$ref": "#/definitions/ElevationRequirement"
},
"InstallationMetadata": {
"$ref": "#/definitions/InstallationMetadata"
}
},
"required": [
Expand Down Expand Up @@ -719,6 +775,9 @@
"RequireExplicitUpgrade": {
"$ref": "#/definitions/RequireExplicitUpgrade"
},
"DisplayInstallWarnings": {
"$ref": "#/definitions/DisplayInstallWarnings"
},
"UnsupportedOSArchitectures": {
"$ref": "#/definitions/UnsupportedOSArchitectures"
},
Expand All @@ -731,8 +790,8 @@
"ElevationRequirement": {
"$ref": "#/definitions/ElevationRequirement"
},
"DisplayInstallWarnings": {
"$ref": "#/definitions/DisplayInstallWarnings"
"InstallationMetadata": {
"$ref": "#/definitions/InstallationMetadata"
},
"Installers": {
"type": "array",
Expand Down
65 changes: 65 additions & 0 deletions schemas/JSON/manifests/v1.3.0/manifest.singleton.1.3.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
"description": "The command alias to be used for calling the package. Only applies to the nested portable package"
}
},
"required": [ "RelativeFilePath" ],
"description": "A nested installer file contained inside an archive"
},
"maxItems": 1024,
Expand Down Expand Up @@ -554,6 +555,58 @@
],
"description": "The installer's elevation requirement"
},
"InstallationMetadata": {
"type": "object",
"title": "InstallationMetadata",
"properties": {
"DefaultInstallLocation": {
"type": [ "string", "null" ],
"minLength": 1,
"maxLength": 2048,
"description": "Represents the default installed package location. Used for deeper installation detection."
},
"Files": {
"type": [ "array", "null" ],
"uniqueItems": true,
"items": {
"type": "object",
"title": "InstalledFile",
"properties": {
"RelativeFilePath": {
"type": "string",
"minLength": 1,
"maxLength": 2048,
"description": "The relative path to the installed file."
},
"FileSha256": {
"type": [ "string", "null" ],
"pattern": "^[A-Fa-f0-9]{64}$",
"description": "Optional Sha256 of the installed file."
},
"FileType": {
"type": [ "string", "null" ],
"enum": [
"launch",
"uninstall",
"other"
],
"description": "The optional installed file type. If not specified, the file is treated as other."
},
"InvocationParameter": {
"type": "string",
"minLength": 1,
"maxLength": 2048,
"description": "Optional parameter for invocable files."
}
},
"required": [ "RelativeFilePath" ],
"description": "Represents an installed file."
},
"description": "List of installed files."
}
},
"description": "Details about the installation. Used for deeper installation detection."
},
"Installer": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -651,6 +704,9 @@
"RequireExplicitUpgrade": {
"$ref": "#/definitions/RequireExplicitUpgrade"
},
"DisplayInstallWarnings": {
"$ref": "#/definitions/DisplayInstallWarnings"
},
"UnsupportedOSArchitectures": {
"$ref": "#/definitions/UnsupportedOSArchitectures"
},
Expand All @@ -662,6 +718,9 @@
},
"ElevationRequirement": {
"$ref": "#/definitions/ElevationRequirement"
},
"InstallationMetadata": {
"$ref": "#/definitions/InstallationMetadata"
}
},
"required": [
Expand Down Expand Up @@ -873,6 +932,9 @@
"RequireExplicitUpgrade": {
"$ref": "#/definitions/RequireExplicitUpgrade"
},
"DisplayInstallWarnings": {
"$ref": "#/definitions/DisplayInstallWarnings"
},
"UnsupportedOSArchitectures": {
"$ref": "#/definitions/UnsupportedOSArchitectures"
},
Expand All @@ -885,6 +947,9 @@
"ElevationRequirement": {
"$ref": "#/definitions/ElevationRequirement"
},
"InstallationMetadata": {
"$ref": "#/definitions/InstallationMetadata"
},
"Installers": {
"type": "array",
"items": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ NestedInstallerType: msi
NestedInstallerFiles:
- RelativeFilePath: RelativeFilePath
PortableCommandAlias: PortableCommandAlias
InstallationMetadata:
DefaultInstallLocation: "%ProgramFiles%\\TestApp"
Files:
- RelativeFilePath: "main.exe"
FileSha256: 69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82
FileType: launch
InvocationParameter: "/arg"

Installers:
- Architecture: x86
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ NestedInstallerType: msi
NestedInstallerFiles:
- RelativeFilePath: RelativeFilePath
PortableCommandAlias: PortableCommandAlias
InstallationMetadata:
DefaultInstallLocation: "%ProgramFiles%\\TestApp"
Files:
- RelativeFilePath: "main.exe"
FileSha256: 69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82
FileType: launch
InvocationParameter: "/arg"

Installers:
- Architecture: x86
Expand Down Expand Up @@ -171,5 +178,12 @@ Installers:
PortableCommandAlias: portableAlias1
- RelativeFilePath: relativeFilePath2
PortableCommandAlias: portableAlias2
InstallationMetadata:
DefaultInstallLocation: "%ProgramFiles%\\TestApp2"
Files:
- RelativeFilePath: "main2.exe"
FileSha256: 69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82
FileType: other
InvocationParameter: "/arg2"
ManifestType: installer
ManifestVersion: 1.3.0
19 changes: 19 additions & 0 deletions src/AppInstallerCLITests/YamlManifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,12 @@ void VerifyV1ManifestContent(const Manifest& manifest, bool isSingleton, Manifes
REQUIRE(manifest.DefaultInstallerInfo.NestedInstallerFiles.size() == 1);
REQUIRE(manifest.DefaultInstallerInfo.NestedInstallerFiles.at(0).RelativeFilePath == "RelativeFilePath");
REQUIRE(manifest.DefaultInstallerInfo.NestedInstallerFiles.at(0).PortableCommandAlias == "PortableCommandAlias");
REQUIRE(manifest.DefaultInstallerInfo.InstallationMetadata.DefaultInstallLocation == "%ProgramFiles%\\TestApp");
REQUIRE(manifest.DefaultInstallerInfo.InstallationMetadata.Files.size() == 1);
REQUIRE(manifest.DefaultInstallerInfo.InstallationMetadata.Files.at(0).RelativeFilePath == "main.exe");
REQUIRE(manifest.DefaultInstallerInfo.InstallationMetadata.Files.at(0).FileType == InstalledFileTypeEnum::Launch);
REQUIRE(manifest.DefaultInstallerInfo.InstallationMetadata.Files.at(0).FileSha256 == SHA256::ConvertToBytes("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82"));
REQUIRE(manifest.DefaultInstallerInfo.InstallationMetadata.Files.at(0).InvocationParameter == "/arg");
}

if (isSingleton)
Expand Down Expand Up @@ -571,6 +577,13 @@ void VerifyV1ManifestContent(const Manifest& manifest, bool isSingleton, Manifes
// NestedInstaller metadata should not be populated unless the InstallerType is zip.
REQUIRE(installer1.NestedInstallerType == InstallerTypeEnum::Unknown);
REQUIRE(installer1.NestedInstallerFiles.size() == 0);

REQUIRE(installer1.InstallationMetadata.DefaultInstallLocation == "%ProgramFiles%\\TestApp");
REQUIRE(installer1.InstallationMetadata.Files.size() == 1);
REQUIRE(installer1.InstallationMetadata.Files.at(0).RelativeFilePath == "main.exe");
REQUIRE(installer1.InstallationMetadata.Files.at(0).FileType == InstalledFileTypeEnum::Launch);
REQUIRE(installer1.InstallationMetadata.Files.at(0).FileSha256 == SHA256::ConvertToBytes("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82"));
REQUIRE(installer1.InstallationMetadata.Files.at(0).InvocationParameter == "/arg");
}

if (!isSingleton)
Expand Down Expand Up @@ -633,6 +646,12 @@ void VerifyV1ManifestContent(const Manifest& manifest, bool isSingleton, Manifes
REQUIRE(installer4.NestedInstallerFiles.at(0).PortableCommandAlias == "portableAlias1");
REQUIRE(installer4.NestedInstallerFiles.at(1).RelativeFilePath == "relativeFilePath2");
REQUIRE(installer4.NestedInstallerFiles.at(1).PortableCommandAlias == "portableAlias2");
REQUIRE(installer4.InstallationMetadata.DefaultInstallLocation == "%ProgramFiles%\\TestApp2");
REQUIRE(installer4.InstallationMetadata.Files.size() == 1);
REQUIRE(installer4.InstallationMetadata.Files.at(0).RelativeFilePath == "main2.exe");
REQUIRE(installer4.InstallationMetadata.Files.at(0).FileType == InstalledFileTypeEnum::Other);
REQUIRE(installer4.InstallationMetadata.Files.at(0).FileSha256 == SHA256::ConvertToBytes("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82"));
REQUIRE(installer4.InstallationMetadata.Files.at(0).InvocationParameter == "/arg2");
}

// Localization
Expand Down
21 changes: 21 additions & 0 deletions src/AppInstallerCommonCore/Manifest/ManifestCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,27 @@ namespace AppInstaller::Manifest
return result;
}

InstalledFileTypeEnum ConvertToInstalledFileTypeEnum(const std::string& in)
{
std::string inStrLower = Utility::ToLower(in);
InstalledFileTypeEnum result = InstalledFileTypeEnum::Unknown;

if (inStrLower == "launch")
{
result = InstalledFileTypeEnum::Launch;
}
else if (inStrLower == "uninstall")
{
result = InstalledFileTypeEnum::Uninstall;
}
else if (inStrLower == "other")
{
result = InstalledFileTypeEnum::Other;
}

return result;
}

std::string_view InstallerTypeToString(InstallerTypeEnum installerType)
{
switch (installerType)
Expand Down
Loading