diff --git a/src/AppInstallerCLICore/PortableInstaller.cpp b/src/AppInstallerCLICore/PortableInstaller.cpp index 9f7e23729c..c0b2708cfc 100644 --- a/src/AppInstallerCLICore/PortableInstaller.cpp +++ b/src/AppInstallerCLICore/PortableInstaller.cpp @@ -281,7 +281,7 @@ namespace AppInstaller::CLI::Portable return true; } - void PortableInstaller::Install( Workflow::OperationType operation = Workflow::OperationType::Install) + void PortableInstaller::Install(Workflow::OperationType operation) { // If the operation is an install, the ARP entry should be created first so that a catastrophic failure // leaves the system in a state where an uninstall may be possible @@ -420,6 +420,19 @@ namespace AppInstaller::CLI::Portable HelpLink = manifest.CurrentLocalization.Get(); } + AppInstaller::Manifest::AppsAndFeaturesEntry PortableInstaller::GetAppsAndFeaturesEntry() + { + Manifest::AppsAndFeaturesEntry entry; + + entry.DisplayName = DisplayName; + entry.Publisher = Publisher; + entry.DisplayVersion = DisplayVersion; + entry.InstallerType = Manifest::InstallerTypeEnum::Portable; + entry.ProductCode = GetProductCode(); + + return entry; + } + void PortableInstaller::SetExpectedState() { const auto& indexPath = InstallLocation / GetPortableIndexFileName(); diff --git a/src/AppInstallerCLICore/PortableInstaller.h b/src/AppInstallerCLICore/PortableInstaller.h index a47d9d1e7a..5dec25063f 100644 --- a/src/AppInstallerCLICore/PortableInstaller.h +++ b/src/AppInstallerCLICore/PortableInstaller.h @@ -59,7 +59,7 @@ namespace AppInstaller::CLI::Portable m_desiredEntries = {}; } - void Install( AppInstaller::CLI::Workflow::OperationType operation ); + void Install(AppInstaller::CLI::Workflow::OperationType operation = Workflow::OperationType::Install); void Uninstall(); @@ -91,6 +91,8 @@ namespace AppInstaller::CLI::Portable const Manifest::Manifest& manifest, const std::vector& entries); + AppInstaller::Manifest::AppsAndFeaturesEntry GetAppsAndFeaturesEntry(); + private: PortableARPEntry m_portableARPEntry; std::vector m_desiredEntries; diff --git a/src/AppInstallerCLICore/Workflows/PortableFlow.cpp b/src/AppInstallerCLICore/Workflows/PortableFlow.cpp index 36c654e237..3f8f852f17 100644 --- a/src/AppInstallerCLICore/Workflows/PortableFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/PortableFlow.cpp @@ -167,7 +167,7 @@ namespace AppInstaller::CLI::Workflow } portableInstaller.TargetInstallLocation = targetInstallDirectory; - portableInstaller.SetAppsAndFeaturesMetadata(context.Get(), context.Get()->AppsAndFeaturesEntries); + portableInstaller.SetAppsAndFeaturesMetadata(context.Get(), installer.AppsAndFeaturesEntries); context.Add(std::move(portableInstaller)); } @@ -273,7 +273,8 @@ namespace AppInstaller::CLI::Workflow } } - portableInstaller.Install(installType); + portableInstaller.Install(installType); + context.Add({ portableInstaller.GetAppsAndFeaturesEntry() }); context.Add(ERROR_SUCCESS); context.Reporter.Warn() << portableInstaller.GetOutputMessage(); } diff --git a/src/AppInstallerCLITests/PortableInstaller.cpp b/src/AppInstallerCLITests/PortableInstaller.cpp index 6b9976b225..c3674c3e7d 100644 --- a/src/AppInstallerCLITests/PortableInstaller.cpp +++ b/src/AppInstallerCLITests/PortableInstaller.cpp @@ -47,6 +47,9 @@ TEST_CASE("PortableInstaller_InstallToRegistry", "[PortableInstaller]") portableInstaller.Install(AppInstaller::CLI::Workflow::OperationType::Install); + auto entry = portableInstaller.GetAppsAndFeaturesEntry(); + REQUIRE(entry.ProductCode == portableInstaller.GetProductCode()); + PortableInstaller portableInstaller2 = PortableInstaller(ScopeEnum::User, Architecture::X64, "testProductCode"); REQUIRE(portableInstaller2.ARPEntryExists()); REQUIRE(std::filesystem::exists(portableInstaller2.PortableTargetFullPath));