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

Download command #3376

Merged
merged 37 commits into from Jul 15, 2023
Merged

Download command #3376

merged 37 commits into from Jul 15, 2023

Conversation

ryfu-msft
Copy link
Contributor

@ryfu-msft ryfu-msft commented Jun 22, 2023

Related to: #2953

Implements the new winget download command.

Changes:

  • Added a new download command with arguments to allow users to download any installer from a package manifest.
  • Added installer-type argument to allow users to select which installertype they would like to download.
  • Also supports scope, locale, and architecture when selecting an installertype.
  • The default behavior is to download installers to the %USERPROFILE%/Downloads/{packageId}.{Version} folder. Users can specify the exact download directory by using the --download-directory argument.
  • Any package dependency installers are installed to a subdirectory called Dependencies so that users can differentiate between the main installer and package dependency installers
  • ManagePackageDependencies has been refactored into CreateDependencySubContexts which is now only responsible for building the dependency graph and populating the context with the package sub contexts execution data.
  • InstallDependencies workflow generates the package dependency sub contexts and installs the package dependencies
  • DownloadDependencies workflow generates the package dependency sub contexts and downloads the package dependencies
  • InstallDependenciesFromCOM only installs the package dependencies (since package dependency sub contexts should have already been created by calling the COMDownloadCommand).

Tests:

  • Added download e2e tests for client and COM to verify the interactions are as expected when calling different arguments and downloading package dependencies.
Microsoft Reviewers: codeflow:open?pullrequest=https://github.com/microsoft/winget-cli/pull/3376&drop=dogfoodAlpha

@github-actions

This comment has been minimized.

@ryfu-msft ryfu-msft changed the title Add support for download command Download command Jun 27, 2023
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@ryfu-msft ryfu-msft marked this pull request as ready for review June 30, 2023 02:40
@ryfu-msft ryfu-msft requested a review from a team as a code owner June 30, 2023 02:40
src/AppInstallerCLICore/Argument.cpp Show resolved Hide resolved
src/Microsoft.Management.Deployment/PackageManager.idl Outdated Show resolved Hide resolved
src/Microsoft.Management.Deployment/PackageManager.idl Outdated Show resolved Hide resolved
src/Microsoft.Management.Deployment/PackageManager.idl Outdated Show resolved Hide resolved
src/Microsoft.Management.Deployment/PackageManager.idl Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Workflows/InstallFlow.cpp Outdated Show resolved Hide resolved
Workflow::ReportDependencies(Resource::String::InstallAndUpgradeCommandsReportDependencies) <<
Workflow::EnableWindowsFeaturesDependencies <<
Workflow::ManagePackageDependencies(Resource::String::InstallAndUpgradeCommandsReportDependencies);
Workflow::ReportDependencies(Resource::String::PackageRequiresDependencies) <<
Copy link
Contributor

Choose a reason for hiding this comment

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

You are probably reporting dependencies twice, try install a package with dependencies to confirm
Update ProcessMultiplePakckages to not report dependencies if m_ignoreDependencies is true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Report dependencies needs to be called here and inside 'ProcessMultiplePackages'. I verified the behavior and it doesn't report dependencies of the same package twice.

The first time ReportDependencies is called is to report the dependencies of the main package. The second time ReportDependencies is called is to the report the dependencies of a dependency package.

This scenario is also utilized by the import command to report dependencies for each package in the subcontexts. If we update ProcessMultiplePackages to not report dependencies if m_ignoreDependencies is true, the import command would fail to display the report dependencies message to the user for each imported package.

installContext << Workflow::ManagePackageDependencies(m_dependenciesReportMessage);
currentContext <<
Workflow::CreateDependencySubContexts(m_dependenciesReportMessage, m_includeInstalledPackages) <<
Workflow::ProcessMultiplePackages(m_dependenciesReportMessage, APPINSTALLER_CLI_ERROR_INSTALL_DEPENDENCIES, {}, false, true, true, true, m_includeInstalledPackages, m_downloadInstallerOnly);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the case for winget import and winget upgrade --all
Here, only package dependencies are considered, we should update the logic to include windows features as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added logic to include support for windows features.

src/AppInstallerCLICore/Workflows/InstallFlow.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Workflows/InstallFlow.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Workflows/InstallFlow.h Outdated Show resolved Hide resolved
m_refreshPathVariable(refreshPathVariable){}
m_refreshPathVariable(refreshPathVariable),
m_includeInstalledPackages(includeInstalledPackages),
m_downloadInstallerOnly(downloadInstallerOnly){}
Copy link
Contributor

Choose a reason for hiding this comment

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

For m_includeInstalledPackages and m_downloadInstallerOnly. As ProcessMultiplePackages is a "one for all" type of workflow, we could just read the context flag and determine the behavior accordingly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed these members as they are not needed. Changed to reading the context flag and determining the bheavior accordingly.

@florelis
Copy link
Member

florelis commented Jul 6, 2023

  • The default behavior is to download installers to the %USERPROFILE%/Downloads/{packageId}.{Version} folder.

I haven't looked at the code yet, but does this work for the msstore source? If so, can we do something different from than {packageId}.{Version}? For example, I'd think the winget package would go to 9NBLGGH4NNS1.Unknown which doesn't help much

@yao-msft
Copy link
Contributor

yao-msft commented Jul 6, 2023

  • The default behavior is to download installers to the %USERPROFILE%/Downloads/{packageId}.{Version} folder.

I haven't looked at the code yet, but does this work for the msstore source? If so, can we do something different from than {packageId}.{Version}? For example, I'd think the winget package would go to 9NBLGGH4NNS1.Unknown which doesn't help much

This code works for win32 apps from msstore. I'll be extending it to work with msstore types later. Maybe to improve it a bit, if version is unknown, we do not concatenate it. Id is the only unique identifier per source. Maybe we can use the id for the directory and PackageName for the installer name?

@ryfu-msft ryfu-msft requested a review from yao-msft July 10, 2023 20:20
src/AppInstallerCLICore/Commands/DownloadCommand.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Workflows/DownloadFlow.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLIE2ETests/TestCommon.cs Outdated Show resolved Hide resolved
src/Microsoft.Management.Deployment/PackageManager.cpp Outdated Show resolved Hide resolved
src/Microsoft.Management.Deployment/PackageManager.cpp Outdated Show resolved Hide resolved
// This must be done before any co_awaits since it requires info from the rpc caller thread.
auto [hrGetCallerId, callerProcessId] = GetCallerProcessId();
WINGET_RETURN_DOWNLOAD_RESULT_HR_IF_FAILED(hrGetCallerId);
WINGET_RETURN_DOWNLOAD_RESULT_HR_IF_FAILED(EnsureProcessHasCapability(Capability::PackageManagement, callerProcessId));
Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, check any one of PackageManagement and PackageQuery exists

src/AppInstallerCLICore/Workflows/ManifestComparator.cpp Outdated Show resolved Hide resolved
@ryfu-msft ryfu-msft merged commit fb3650a into microsoft:master Jul 15, 2023
8 checks passed
@ryfu-msft ryfu-msft deleted the downloadCommand branch July 15, 2023 02:16
@CanePlayz
Copy link

If this isn't the right place to ask, feel free to delete it.

Users can specify the exact download directory by using the --download-directory argument.

The spec also mentioned a parameter "--fileName". Has this been implemented as well?

@yao-msft
Copy link
Contributor

The spec also mentioned a parameter "--fileName". Has this been implemented as well?

There may be more than one packages downloaded if dependencies are included, and we think current naming strategy is unique enough to prevent confliction, so we removed the --file-name arg. Spec will be updated once the final implementation is done.

@CanePlayz
Copy link

The spec also mentioned a parameter "--fileName". Has this been implemented as well?

There may be more than one packages downloaded if dependencies are included, and we think current naming strategy is unique enough to prevent confliction, so we removed the --file-name arg. Spec will be updated once the final implementation is done.

Good point, that could be a conflict. I guess I'll try to rename the files in my workflow with another part of my script then.

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.

None yet

6 participants