commit dfe9a0fb17d18b61d0ad95ddbb7a38f8b805a54e
parent b357fe885fe3fa566bfa5d9ae9b0fdb75a2542d0
Author: yao-msft <50888816+yao-msft@users.noreply.github.com>
Date: Fri, 20 Oct 2023 12:18:35 -0700
Download and install Workflow patches for skip dependencies (#3794)
Diffstat:
8 files changed, 55 insertions(+), 34 deletions(-)
diff --git a/src/AppInstallerCLICore/Commands/InstallCommand.cpp b/src/AppInstallerCLICore/Commands/InstallCommand.cpp
@@ -139,13 +139,15 @@ namespace AppInstaller::CLI
if (context.Args.Contains(Execution::Args::Type::MultiQuery))
{
+ bool skipDependencies = Settings::User().Get<Settings::Setting::InstallSkipDependencies>() || context.Args.Contains(Execution::Args::Type::SkipDependencies);
context <<
Workflow::GetMultiSearchRequests <<
Workflow::SearchSubContextsForSingle() <<
Workflow::ReportExecutionStage(Workflow::ExecutionStage::Execution) <<
Workflow::ProcessMultiplePackages(
Resource::String::PackageRequiresDependencies,
- APPINSTALLER_CLI_ERROR_MULTIPLE_INSTALL_FAILED);
+ APPINSTALLER_CLI_ERROR_MULTIPLE_INSTALL_FAILED,
+ {}, true, skipDependencies);
}
else
{
diff --git a/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp b/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp
@@ -199,13 +199,15 @@ namespace AppInstaller::CLI
}
else
{
+ bool skipDependencies = Settings::User().Get<Settings::Setting::InstallSkipDependencies>() || context.Args.Contains(Execution::Args::Type::SkipDependencies);
context <<
Workflow::GetMultiSearchRequests <<
Workflow::SearchSubContextsForSingle(OperationType::Upgrade) <<
Workflow::ReportExecutionStage(Workflow::ExecutionStage::Execution) <<
Workflow::ProcessMultiplePackages(
Resource::String::PackageRequiresDependencies,
- APPINSTALLER_CLI_ERROR_MULTIPLE_INSTALL_FAILED);
+ APPINSTALLER_CLI_ERROR_MULTIPLE_INSTALL_FAILED,
+ {}, true, skipDependencies);
}
}
}
diff --git a/src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp b/src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp
@@ -5,6 +5,7 @@
#include "ImportExportFlow.h"
#include "UpdateFlow.h"
#include "PackageCollection.h"
+#include "DependenciesFlow.h"
#include "WorkflowBase.h"
#include <winget/RepositorySearch.h>
#include <winget/Runtime.h>
@@ -305,8 +306,19 @@ namespace AppInstaller::CLI::Workflow
void InstallImportedPackages(Execution::Context& context)
{
- context << Workflow::ProcessMultiplePackages(
- Resource::String::ImportCommandReportDependencies, APPINSTALLER_CLI_ERROR_IMPORT_INSTALL_FAILED, {}, true, true);
+ // Inform all dependencies here. During SubContexts processing, dependencies are ignored.
+ auto& packageSubContexts = context.Get<Execution::Data::PackageSubContexts>();
+ Manifest::DependencyList allDependencies;
+ for (auto& packageContext : packageSubContexts)
+ {
+ allDependencies.Add(packageContext->Get<Execution::Data::Installer>().value().Dependencies);
+ }
+ context.Add<Execution::Data::Dependencies>(allDependencies);
+
+ context <<
+ Workflow::ReportDependencies(Resource::String::ImportCommandReportDependencies) <<
+ Workflow::ProcessMultiplePackages(
+ Resource::String::ImportCommandReportDependencies, APPINSTALLER_CLI_ERROR_IMPORT_INSTALL_FAILED, {}, true, true);
if (context.GetTerminationHR() == APPINSTALLER_CLI_ERROR_IMPORT_INSTALL_FAILED)
{
diff --git a/src/AppInstallerCLICore/Workflows/InstallFlow.cpp b/src/AppInstallerCLICore/Workflows/InstallFlow.cpp
@@ -547,7 +547,7 @@ namespace AppInstaller::CLI::Workflow
Workflow::GetDependenciesFromInstaller <<
Workflow::ReportDependencies(Resource::String::PackageRequiresDependencies) <<
Workflow::EnableWindowsFeaturesDependencies <<
- Workflow::ProcessMultiplePackages(Resource::String::PackageRequiresDependencies, APPINSTALLER_CLI_ERROR_INSTALL_DEPENDENCIES, {}, false, true, true, true);
+ Workflow::ProcessMultiplePackages(Resource::String::PackageRequiresDependencies, APPINSTALLER_CLI_ERROR_INSTALL_DEPENDENCIES, {}, true, true, true, true);
}
void DownloadPackageDependencies(Execution::Context& context)
@@ -619,40 +619,44 @@ namespace AppInstaller::CLI::Workflow
return;
}
+ bool downloadInstallerOnly = WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerDownloadOnly);
+
// Show all prompts needed for every package before installing anything
- context << Workflow::ShowPromptsForMultiplePackages(m_ensurePackageAgreements);
+ context << Workflow::ShowPromptsForMultiplePackages(m_ensurePackageAgreements, downloadInstallerOnly);
if (context.IsTerminated())
{
return;
}
- bool downloadInstallerOnly = WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerDownloadOnly);
-
// Report dependencies
- auto& packageSubContexts = context.Get<Execution::Data::PackageSubContexts>();
- if (!packageSubContexts.empty())
+ if (!m_ignorePackageDependencies)
{
- if (downloadInstallerOnly)
+ auto& packageSubContexts = context.Get<Execution::Data::PackageSubContexts>();
+
+ DependencyList allDependencies;
+
+ for (auto& packageContext : packageSubContexts)
{
- context.Reporter.Info() << Resource::String::DependenciesFlowDownload << std::endl;
+ allDependencies.Add(packageContext->Get<Execution::Data::Installer>().value().Dependencies);
}
- else
+
+ if (!allDependencies.Empty())
{
- context.Reporter.Info() << Resource::String::DependenciesFlowInstall << std::endl;
+ if (downloadInstallerOnly)
+ {
+ context.Reporter.Info() << Resource::String::DependenciesFlowDownload << std::endl;
+ }
+ else
+ {
+ context.Reporter.Info() << Resource::String::DependenciesFlowInstall << std::endl;
+ }
}
- }
-
- DependencyList allDependencies;
- for (auto& packageContext : packageSubContexts)
- {
- allDependencies.Add(packageContext->Get<Execution::Data::Installer>().value().Dependencies);
+ context.Add<Execution::Data::Dependencies>(allDependencies);
+ context << Workflow::ReportDependencies(m_dependenciesReportMessage);
}
- context.Add<Execution::Data::Dependencies>(allDependencies);
- context << Workflow::ReportDependencies(m_dependenciesReportMessage);
-
bool allSucceeded = true;
size_t packagesCount = context.Get<Execution::Data::PackageSubContexts>().size();
size_t packagesProgress = 0;
@@ -671,14 +675,11 @@ namespace AppInstaller::CLI::Workflow
// Prevent individual exceptions from breaking out of the loop
try
{
- if (!m_ignorePackageDependencies)
+ // Handle dependencies if requested.
+ if (!m_ignorePackageDependencies && !downloadInstallerOnly)
{
- if (!downloadInstallerOnly)
- {
- currentContext << Workflow::EnableWindowsFeaturesDependencies;
- }
-
currentContext <<
+ Workflow::EnableWindowsFeaturesDependencies <<
Workflow::CreateDependencySubContexts(m_dependenciesReportMessage) <<
Workflow::ProcessMultiplePackages(m_dependenciesReportMessage, APPINSTALLER_CLI_ERROR_INSTALL_DEPENDENCIES, {}, true, true, true, true);
}
diff --git a/src/AppInstallerCLICore/Workflows/InstallFlow.h b/src/AppInstallerCLICore/Workflows/InstallFlow.h
@@ -142,7 +142,7 @@ namespace AppInstaller::CLI::Workflow
// Outputs: None
void InstallPackageInstaller(Execution::Context& context);
- // Installs the dependencies for a specific package.
+ // Installs the dependencies for a specific package. CreateDependencySubContexts should have been called before this task.
// Required Args: None
// Inputs: InstallerPath, Manifest, Installer, PackageVersion, InstalledPackageVersion?
// Outputs: None
diff --git a/src/AppInstallerCLICore/Workflows/PromptFlow.cpp b/src/AppInstallerCLICore/Workflows/PromptFlow.cpp
@@ -435,7 +435,7 @@ namespace AppInstaller::CLI::Workflow
void ShowPromptsForMultiplePackages::operator()(Execution::Context& context) const
{
- for (auto& prompt : GetPackagePrompts(m_ensureAgreementsAcceptance))
+ for (auto& prompt : GetPackagePrompts(m_ensureAgreementsAcceptance, m_installerDownloadOnly))
{
// Find which packages need this prompt
std::vector<Execution::Context*> packagesToPrompt;
diff --git a/src/AppInstallerCLICore/Workflows/PromptFlow.h b/src/AppInstallerCLICore/Workflows/PromptFlow.h
@@ -40,13 +40,15 @@ namespace AppInstaller::CLI::Workflow
// Outputs: None
struct ShowPromptsForMultiplePackages : public WorkflowTask
{
- ShowPromptsForMultiplePackages(bool ensureAgreementsAcceptance) :
- WorkflowTask("ShowPromptsForMultiplePackages"), m_ensureAgreementsAcceptance(ensureAgreementsAcceptance) {}
+ ShowPromptsForMultiplePackages(bool ensureAgreementsAcceptance, bool installerDownloadOnly) :
+ WorkflowTask("ShowPromptsForMultiplePackages"), m_ensureAgreementsAcceptance(ensureAgreementsAcceptance),
+ m_installerDownloadOnly(installerDownloadOnly) {}
void operator()(Execution::Context& context) const override;
private:
bool m_ensureAgreementsAcceptance;
+ bool m_installerDownloadOnly;
};
// If the context is not interactive, terminate it with the given HRESULT.
diff --git a/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp b/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp
@@ -263,11 +263,13 @@ namespace AppInstaller::CLI::Workflow
{
context.Add<Execution::Data::PackageSubContexts>(std::move(packageSubContexts));
context.Reporter.Info() << std::endl;
+ bool skipDependencies = Settings::User().Get<Settings::Setting::InstallSkipDependencies>() || context.Args.Contains(Execution::Args::Type::SkipDependencies);
context <<
ProcessMultiplePackages(
Resource::String::PackageRequiresDependencies,
APPINSTALLER_CLI_ERROR_UPDATE_ALL_HAS_FAILURE,
- { APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE });
+ { APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE },
+ true, skipDependencies);
}
if (packagesWithUnknownVersionSkipped > 0)