public async ValueTask InstallPackagesAsync( string projectId, IReadOnlyList <PackageIdentity> packageIdentities, CancellationToken cancellationToken) { Assumes.NotNullOrEmpty(projectId); Assumes.NotNullOrEmpty(packageIdentities); cancellationToken.ThrowIfCancellationRequested(); NuGetProject?project = await SolutionUtility.GetNuGetProjectAsync( _state.SolutionManager, projectId, cancellationToken); Assumes.NotNull(project); SourceRepository?sourceRepository = await GetSourceRepositoryAsync(cancellationToken); IEnumerable <NuGetProjectAction>?actions = packageIdentities .Select(packageIdentity => NuGetProjectAction.CreateInstallProjectAction(packageIdentity, sourceRepository, project)); NuGetPackageManager packageManager = await _state.GetPackageManagerAsync(cancellationToken); Assumes.NotNull(packageManager); INuGetProjectContext projectContext = await ServiceLocator.GetComponentModelServiceAsync <INuGetProjectContext>(); Assumes.NotNull(projectContext); await packageManager.ExecuteBuildIntegratedProjectActionsAsync( project as BuildIntegratedNuGetProject, actions, projectContext, cancellationToken); }