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 scope support to more commands and add provisioning support for msix and msstore types #2766

Merged
merged 19 commits into from
Dec 16, 2022

Conversation

yao-msft
Copy link
Contributor

@yao-msft yao-msft commented Dec 14, 2022

  • Add scope parameter support to show, list, upgrade and uninstall commands
    Scope parameter in list, upgrade and uninstall commands works slightly differently from install and show commands.
    Show, install commands: scope parameter is to filter the installer selection
    List, upgrade and uninstall: scope parameter is to filter the installed package selection, for upgrade, that means the package to upgrade is also filtered to the scope due to the InstalledScopeFilter in ManifestComparator
  • Rewrite GetPackageFullNameFromFamilyName to use PackageManager methods to support system callers
  • Add provisioning support for msix and msstore types when scope is machine
  • Added e2e tests
Microsoft Reviewers: Open in CodeFlow

@yao-msft yao-msft marked this pull request as ready for review December 15, 2022 22:16
@yao-msft yao-msft requested a review from a team as a code owner December 15, 2022 22:16
@@ -121,16 +133,29 @@ namespace AppInstaller::Repository::Microsoft
SQLiteIndex index = SQLiteIndex::CreateNew(SQLITE_MEMORY_DB_CONNECTION_TARGET, Schema::Version::Latest());

// Put installed packages into the index
if (filter == PredefinedInstalledSourceFactory::Filter::None || filter == PredefinedInstalledSourceFactory::Filter::ARP)
if (filter == PredefinedInstalledSourceFactory::Filter::None || filter == PredefinedInstalledSourceFactory::Filter::ARP ||
filter == PredefinedInstalledSourceFactory::Filter::User || filter == PredefinedInstalledSourceFactory::Filter::Machine)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this done on purpose for readability? Could be simplified to:

if (filter != PredefinedInstalledSourceFactory::Filter::Msix)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be better to check expected values instead of "!=" so future additions of the enum will not accidentally change previous behavior

Comment on lines +150 to 159
if (filter == PredefinedInstalledSourceFactory::Filter::None ||
filter == PredefinedInstalledSourceFactory::Filter::MSIX ||
filter == PredefinedInstalledSourceFactory::Filter::User)
{
PopulateIndexFromMSIX(index);
PopulateIndexFromMSIX(index, Manifest::ScopeEnum::User);
}
else if (filter == PredefinedInstalledSourceFactory::Filter::Machine)
{
PopulateIndexFromMSIX(index, Manifest::ScopeEnum::Machine);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (filter != PredefinedInstalledSourceFactory::Filter::Arp)
{
    if (filter == PredefinedInstalledSourceFactory::Filter::Machine)
    {
        PopulateIndexFromMSIX(index, Manifest::ScopeEnum::Machine);
    }
    else
    {
        PopulateIndexFromMSIX(index, Manifest::ScopeEnum::User);
    }
}

::AppInstaller::Repository::Source installedSource = ::AppInstaller::Repository::Source{ ::AppInstaller::Repository::PredefinedSource::Installed };
::AppInstaller::Repository::Source installedSource;
auto manifestInstalledScope = GetManifestScope(m_compositePackageCatalogOptions.InstalledScope());
if (manifestInstalledScope.first == ::AppInstaller::Manifest::ScopeEnum::User)
Copy link
Contributor

@ryfu-msft ryfu-msft Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: seems like you can just assign manifestInstalledScope.first directly to the local variable.

if (installerType == InstallerTypeEnum::Portable ||
installerType == InstallerTypeEnum::MSStore ||
installerType == InstallerTypeEnum::Msix)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use semantic check like IsAdminRequiredForMachineScopeInstall(installerType)

@@ -133,6 +134,11 @@ namespace AppInstaller::CLI::Workflow
installOptions.CompletedInstallToastNotificationMode(AppInstallationToastNotificationMode::NoToast);
}

if (Manifest::ConvertToScopeEnum(context.Args.GetArg(Execution::Args::Type::InstallScope)) == Manifest::ScopeEnum::Machine)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (Manifest::ConvertToScopeEnum(context.Args.GetArg(Execution::Args::Type::InstallScope)) == Manifest::ScopeEnum::Machine)

Do we need to check if the InstallScope arg exists before calling this to prevent an exception from being thrown?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If arg does not exist, the GetArg returns empty, no exception is thrown. I copied this snippet from existing usage in other places.

@yao-msft yao-msft merged commit 0853f0e into microsoft:master Dec 16, 2022
@yao-msft yao-msft deleted the systemscope branch December 16, 2022 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants