diff --git a/src/AppInstallerCLICore/Workflows/PortableFlow.cpp b/src/AppInstallerCLICore/Workflows/PortableFlow.cpp index 7a34b52623..36c654e237 100644 --- a/src/AppInstallerCLICore/Workflows/PortableFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/PortableFlow.cpp @@ -111,9 +111,14 @@ namespace AppInstaller::CLI::Workflow { Manifest::ScopeEnum scope = Manifest::ScopeEnum::Unknown; bool isUpdate = WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerExecutionUseUpdate); - if (isUpdate) + std::shared_ptr installedVersion; + if (context.Contains(Execution::Data::InstalledPackageVersion)) { - IPackageVersion::Metadata installationMetadata = context.Get()->GetMetadata(); + installedVersion = context.Get(); + } + if (isUpdate && installedVersion) + { + IPackageVersion::Metadata installationMetadata = installedVersion->GetMetadata(); auto installerScopeItr = installationMetadata.find(Repository::PackageVersionMetadata::InstalledScope); if (installerScopeItr != installationMetadata.end()) {