await PreviewBuildIntegratedProjectActionsAsync()

in src/NuGet.Core/NuGet.PackageManagement/NuGetPackageManager.cs [1564:1789]


                        await PreviewBuildIntegratedProjectActionsAsync(buildIntegratedProject, actions, nuGetProjectContext, token)
                    };
                }

                return actions;
            }

            var primarySources = new List<SourceRepository> { primarySourceRepository };
            return await PreviewInstallPackageAsync(nuGetProject, packageIdentity, resolutionContext,
                nuGetProjectContext, primarySources, secondarySources, token);
        }

        public async Task<IEnumerable<ResolvedAction>> PreviewProjectsInstallPackageAsync(
            IReadOnlyCollection<NuGetProject> nuGetProjects,
            PackageIdentity packageIdentity,
            ResolutionContext resolutionContext,
            INuGetProjectContext nuGetProjectContext,
            IReadOnlyCollection<SourceRepository> activeSources,
            CancellationToken token)
        {
            return await PreviewProjectsInstallPackageAsync(nuGetProjects, packageIdentity, resolutionContext, nuGetProjectContext, activeSources, versionRange: null, token);
        }

        public async Task<IEnumerable<ResolvedAction>> PreviewProjectsInstallPackageAsync(
            IReadOnlyCollection<NuGetProject> nuGetProjects,
            PackageIdentity packageIdentity,
            ResolutionContext resolutionContext,
            INuGetProjectContext nuGetProjectContext,
            IReadOnlyCollection<SourceRepository> activeSources,
            VersionRange versionRange,
            CancellationToken token)
        {
            return await PreviewProjectsInstallPackageAsync(
                nuGetProjects,
                packageIdentity,
                resolutionContext,
                nuGetProjectContext,
                activeSources,
                versionRange,
                newMappingID: null,
                newMappingSource: null,
                token);
        }

        // Preview and return ResolvedActions for many NuGetProjects.
        public async Task<IEnumerable<ResolvedAction>> PreviewProjectsInstallPackageAsync(
            IReadOnlyCollection<NuGetProject> nuGetProjects,
            PackageIdentity packageIdentity,
            ResolutionContext resolutionContext,
            INuGetProjectContext nuGetProjectContext,
            IReadOnlyCollection<SourceRepository> activeSources,
            VersionRange versionRange,
            string newMappingID,
            string newMappingSource,
            CancellationToken token)
        {
            if (nuGetProjects == null)
            {
                throw new ArgumentNullException(nameof(nuGetProjects));
            }

            if (packageIdentity == null)
            {
                throw new ArgumentNullException(nameof(packageIdentity));
            }

            if (resolutionContext == null)
            {
                throw new ArgumentNullException(nameof(resolutionContext));
            }

            if (nuGetProjectContext == null)
            {
                throw new ArgumentNullException(nameof(nuGetProjectContext));
            }

            if (activeSources == null)
            {
                throw new ArgumentNullException(nameof(activeSources));
            }

            if (activeSources.Count == 0)
            {
                throw new ArgumentException("At least 1 item expected for " + nameof(activeSources));
            }

            if (packageIdentity.Version == null)
            {
                throw new ArgumentNullException(nameof(packageIdentity));
            }

            var results = new List<ResolvedAction>();

            // BuildIntegratedNuGetProject type projects are now supports parallel preview action for faster performance.
            var buildIntegratedProjectsToUpdate = new List<BuildIntegratedNuGetProject>();
            // Currently packages.config projects are not supported are supports parallel previews.
            // Here is follow up issue to address it https://github.com/NuGet/Home/issues/9906
            var otherTargetProjectsToUpdate = new List<NuGetProject>();

            foreach (var proj in nuGetProjects)
            {
                if (proj is BuildIntegratedNuGetProject buildIntegratedNuGetProject)
                {
                    buildIntegratedProjectsToUpdate.Add(buildIntegratedNuGetProject);
                }
                else
                {
                    otherTargetProjectsToUpdate.Add(proj);
                }
            }

            if (buildIntegratedProjectsToUpdate.Count != 0)
            {
                // Only automatically create Source Mappings when there's exclusively BuildIntegratedProjects.
                if (otherTargetProjectsToUpdate.Count > 0)
                {
                    newMappingID = null;
                    newMappingSource = null;
                }

                // Run build integrated project preview for all projects at the same time
                var resolvedActions = await PreviewBuildIntegratedProjectsActionsAsync(
                    buildIntegratedProjectsToUpdate,
                    nugetProjectActionsLookup: null, // no nugetProjectActionsLookup so it'll be derived from packageIdentity and activeSources
                    packageIdentity,
                    activeSources,
                    nuGetProjectContext,
                    versionRange,
                    newMappingID,
                    newMappingSource,
                    token);
                results.AddRange(resolvedActions);
            }

            foreach (var target in otherTargetProjectsToUpdate)
            {
                var actions = await PreviewInstallPackageAsync(
                    target,
                    packageIdentity,
                    resolutionContext,
                    nuGetProjectContext,
                    activeSources,
                    null,
                    token);
                results.AddRange(actions.Select(a => new ResolvedAction(target, a)));
            }

            return results;
        }

        public async Task<IEnumerable<NuGetProjectAction>> PreviewInstallPackageAsync(
            NuGetProject nuGetProject,
            PackageIdentity packageIdentity,
            ResolutionContext resolutionContext,
            INuGetProjectContext nuGetProjectContext,
            IEnumerable<SourceRepository> primarySources,
            IEnumerable<SourceRepository> secondarySources,
            CancellationToken token)
        {
            return await PreviewInstallPackageAsync(nuGetProject, packageIdentity, resolutionContext, nuGetProjectContext, primarySources, secondarySources, versionRange: null, token);
        }

        public async Task<IEnumerable<NuGetProjectAction>> PreviewInstallPackageAsync(
            NuGetProject nuGetProject,
            PackageIdentity packageIdentity,
            ResolutionContext resolutionContext,
            INuGetProjectContext nuGetProjectContext,
            IEnumerable<SourceRepository> primarySources,
            IEnumerable<SourceRepository> secondarySources,
            VersionRange versionRange,
            CancellationToken token)
        {
            if (nuGetProject == null)
            {
                throw new ArgumentNullException(nameof(nuGetProject));
            }

            if (packageIdentity == null)
            {
                throw new ArgumentNullException(nameof(packageIdentity));
            }

            if (resolutionContext == null)
            {
                throw new ArgumentNullException(nameof(resolutionContext));
            }

            if (nuGetProjectContext == null)
            {
                throw new ArgumentNullException(nameof(nuGetProjectContext));
            }

            if (primarySources == null)
            {
                throw new ArgumentNullException(nameof(primarySources));
            }

            if (secondarySources == null)
            {
                secondarySources = SourceRepositoryProvider.GetRepositories().Where(e => e.PackageSource.IsEnabled);
            }

            if (!primarySources.Any())
            {
                throw new ArgumentException(
                    message: Strings.Argument_Cannot_Be_Null_Or_Empty,
                    paramName: nameof(primarySources));
            }

            if (packageIdentity.Version == null)
            {
                throw new ArgumentException(
                    message: string.Format(CultureInfo.CurrentCulture, Strings.PropertyCannotBeNull, nameof(packageIdentity.Version)),
                    paramName: nameof(packageIdentity));
            }

            if (nuGetProject is INuGetIntegratedProject)
            {
                var action = NuGetProjectAction.CreateInstallProjectAction(packageIdentity, primarySources.First(), nuGetProject, versionRange);
                var actions = new[] { action };

                var buildIntegratedProject = nuGetProject as BuildIntegratedNuGetProject;

                if (buildIntegratedProject != null)
                {
                    actions = new[] {