Exemple #1
0
        public void PerformUpToDateCheck_WhenALeafProjectHasNoGlobalPackagesFolder_ReturnsOnlyThatProject()
        {
            using (var testDirectory = TestDirectory.Create())
            {
                var projectA = GetPackageSpec("A", testDirectory.Path);
                var projectB = GetPackageSpec("B", testDirectory.Path);
                var projectC = GetPackageSpec("C", testDirectory.Path);
                projectC.RestoreMetadata.PackagesPath = Path.Combine(testDirectory.Path, "gpf");
                // A => B
                projectA = projectA.WithTestProjectReference(projectB);
                // B => C
                projectB = projectB.WithTestProjectReference(projectC);
                DependencyGraphSpec dgSpec = ProjectTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC);

                var checker = new SolutionUpToDateChecker();

                // Preconditions, run 1st check
                var actual   = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance);
                var expected = GetUniqueNames(projectA, projectB, projectC);
                actual.Should().BeEquivalentTo(expected);
                var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC);
                checker.SaveRestoreStatus(results);

                // Set-up, delete C's outputs
                Directory.Delete(projectC.RestoreMetadata.PackagesPath, recursive: true);

                // Act & Assert
                actual   = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance);
                expected = GetUniqueNames(projectC);
                actual.Should().BeEquivalentTo(expected);
            }
        }
Exemple #2
0
        public void PerformUpToDateCheck_LeafProjectChanges_ReturnsAllItsParents()
        {
            using (var testDirectory = TestDirectory.Create())
            {
                var projectA = GetPackageSpec("A", testDirectory.Path);
                var projectB = GetPackageSpec("B", testDirectory.Path);
                var projectC = GetPackageSpec("C", testDirectory.Path);
                var projectD = GetPackageSpec("D", testDirectory.Path);

                // A => B
                projectA = projectA.WithTestProjectReference(projectB);
                // B => C
                projectB = projectB.WithTestProjectReference(projectC);
                DependencyGraphSpec dgSpec = ProjectTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD);

                var checker = new SolutionUpToDateChecker();

                // Preconditions, run 1st check
                var actual   = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance);
                var expected = GetUniqueNames(projectA, projectB, projectC, projectD);
                actual.Should().BeEquivalentTo(expected);
                var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC, projectD);
                checker.SaveRestoreStatus(results);

                // Set-up, B => D
                projectB = projectB.WithTestProjectReference(projectD);
                dgSpec   = ProjectTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD);

                // Act & Assert
                actual   = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance);
                expected = GetUniqueNames(projectA, projectB);
                actual.Should().BeEquivalentTo(expected);
            }
        }
        public async Task RestoreAsync_WithProgressReporter_WhenFilesAreWriten_ProgressIsReported()
        {
            // Arrange
            using var pathContext = new SimpleTestPathContext();
            var settings         = Settings.LoadDefaultSettings(pathContext.SolutionRoot);
            var packageSpec      = ProjectTestHelpers.GetPackageSpec(settings, projectName: "projectName", rootPath: pathContext.SolutionRoot);
            var progressReporter = new Mock <IRestoreProgressReporter>();

            // Act
            IReadOnlyList <RestoreSummary> result = await DependencyGraphRestoreUtility.RestoreAsync(
                ProjectTestHelpers.GetDGSpecFromPackageSpecs(packageSpec),
                new DependencyGraphCacheContext(),
                new RestoreCommandProvidersCache(),
                cacheContextModifier : _ => { },
                sources : new SourceRepository[0],
                parentId : Guid.Empty,
                forceRestore : false,
                isRestoreOriginalAction : true,
                additionalMessages : null,
                progressReporter : progressReporter.Object,
                new TestLogger(),
                CancellationToken.None);

            // Assert
            result.Should().HaveCount(1);
            RestoreSummary restoreSummary = result[0];

            restoreSummary.Success.Should().BeTrue();
            restoreSummary.NoOpRestore.Should().BeFalse();
            var assetsFilePath = Path.Combine(packageSpec.RestoreMetadata.OutputPath, LockFileFormat.AssetsFileName);

            File.Exists(assetsFilePath).Should().BeTrue(because: $"{assetsFilePath}");

            var propsFile   = BuildAssetsUtils.GetMSBuildFilePath(packageSpec, BuildAssetsUtils.PropsExtension);
            var targetsFile = BuildAssetsUtils.GetMSBuildFilePath(packageSpec, BuildAssetsUtils.TargetsExtension);

            IReadOnlyList <string> expectedFileList = new string[] { assetsFilePath, propsFile, targetsFile };
            var pathComparer = PathUtility.GetStringComparerBasedOnOS();

            progressReporter.Verify(r =>
                                    r.StartProjectUpdate(
                                        It.Is <string>(e => e.Equals(packageSpec.FilePath)),
                                        It.Is <IReadOnlyList <string> >(e => e.OrderedEquals(expectedFileList, (f) => f, pathComparer, pathComparer))),
                                    Times.Once);
            progressReporter.Verify(r =>
                                    r.EndProjectUpdate(
                                        It.Is <string>(e => e.Equals(packageSpec.FilePath)),
                                        It.Is <IReadOnlyList <string> >(e => e.OrderedEquals(expectedFileList, (f) => f, pathComparer, pathComparer))),
                                    Times.Once);
        }
Exemple #4
0
        private static void AddPackageDependency(ProjectSystemCache projectSystemCache, ProjectNames projectNames, PackageSpec packageSpec, SimpleTestPackageContext package)
        {
            var dependency = new LibraryDependency()
            {
                LibraryRange = new LibraryRange(
                    name: package.Id,
                    versionRange: new VersionRange(package.Identity.Version),
                    typeConstraint: LibraryDependencyTarget.Package)
            };

            packageSpec.TargetFrameworks.First().Dependencies.Add(dependency);
            DependencyGraphSpec projectRestoreInfo = ProjectTestHelpers.GetDGSpecFromPackageSpecs(packageSpec);

            projectSystemCache.AddProjectRestoreInfo(projectNames, projectRestoreInfo, Array.Empty <IAssetsLogMessage>());
        }
Exemple #5
0
        public void ReportStatus_WhenPartialResultsAreAvailable_OldStatusIsRetained()
        {
            using (var testDirectory = TestDirectory.Create())
            {
                var projectA = GetPackageSpec("A", testDirectory.Path);
                var projectB = GetPackageSpec("B", testDirectory.Path);
                var projectC = GetPackageSpec("C", testDirectory.Path);
                var projectD = GetPackageSpec("D", testDirectory.Path);
                var projectE = GetPackageSpec("E", testDirectory.Path);

                // A => B
                projectA = projectA.WithTestProjectReference(projectB);
                // B => C
                projectB = projectB.WithTestProjectReference(projectC);
                // A => D
                projectA = projectA.WithTestProjectReference(projectD);

                DependencyGraphSpec dgSpec = ProjectTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD, projectE);

                var checker = new SolutionUpToDateChecker();

                // Preconditions, run 1st check
                var actual   = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance);
                var expected = GetUniqueNames(projectA, projectB, projectC, projectD, projectE);
                actual.Should().BeEquivalentTo(expected);
                var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC, projectD, projectE);
                checker.SaveRestoreStatus(results);

                // D => E
                projectD = projectD.WithTestProjectReference(projectE);

                // Set-up dg spec
                dgSpec = ProjectTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD, projectE);
                // 2nd check
                actual   = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance);
                expected = GetUniqueNames(projectA, projectD);
                actual.Should().BeEquivalentTo(expected);
                results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectD);
                checker.SaveRestoreStatus(results);

                // Finally, last check. Run for a 3rd time. Everything should be up to date
                actual   = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance);
                expected = GetUniqueNames();
                actual.Should().BeEquivalentTo(expected);
            }
        }
Exemple #6
0
        public void PerformUpToDateCheck_WhenNonBuildIntegratedProjectIsAParentOfADirtySpec_ReturnsAListWithoutNonBuildIntegratedProjects()
        {
            var projectA = GetPackageSpec("A");
            var projectB = GetPackageSpec("B");
            var projectC = GetPackageSpec("C");
            var projectD = GetPackageSpec("D");
            var projectE = GetPackageSpec("E");
            var projectF = GetUnknownPackageSpec("F");

            // A => B & D & E
            projectA = projectA.WithTestProjectReference(projectB).WithTestProjectReference(projectD).WithTestProjectReference(projectE);
            // B => C
            projectB = projectB.WithTestProjectReference(projectC);
            // E => F
            projectE = projectE.WithTestProjectReference(projectF);

            DependencyGraphSpec dgSpec = ProjectTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD, projectE, projectF);

            var checker = new SolutionUpToDateChecker();

            var actual   = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance);
            var expected = GetUniqueNames(projectA, projectB, projectC, projectD, projectE);

            actual.Should().BeEquivalentTo(expected);

            // Now we run
            var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC, projectD, projectE);

            checker.SaveRestoreStatus(results);

            // Prepare the new DG Spec:
            // Make projectE dirty by setting a random value that's usually not there :)
            projectF = projectF.Clone();
            projectF.RestoreMetadata.PackagesPath = @"C:\";
            dgSpec = ProjectTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD, projectE, projectF);

            // Act & Assert.
            expected = GetUniqueNames(projectA, projectE);
            actual   = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance);
            actual.Should().BeEquivalentTo(expected);
        }
Exemple #7
0
        public void PerformUpToDateCheck_WithFailedPastRestore_ReturnsADirtyProject()
        {
            using (var testDirectory = TestDirectory.Create())
            {
                var projectA = GetPackageSpec("A", testDirectory.Path);
                var projectB = GetPackageSpec("B", testDirectory.Path);
                var projectC = GetPackageSpec("C", testDirectory.Path);

                // A => B
                projectA = projectA.WithTestProjectReference(projectB);
                // B => C
                projectB = projectB.WithTestProjectReference(projectC);
                DependencyGraphSpec dgSpec = ProjectTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC);

                var checker = new SolutionUpToDateChecker();

                // Preconditions, run 1st check
                var actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance);
                new List <string>()
                {
                    projectA.RestoreMetadata.ProjectUniqueName, projectB.RestoreMetadata.ProjectUniqueName, projectC.RestoreMetadata.ProjectUniqueName
                }.Should().BeEquivalentTo(actual);

                // Set-up, ensure the last status for projectC is a failure.
                var results = RunRestore(failedProjects: new HashSet <string>()
                {
                    projectC.RestoreMetadata.ProjectUniqueName
                }, projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC);
                checker.SaveRestoreStatus(results);

                // Act & Assert
                actual = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance);
                var expected = new List <string>()
                {
                    projectC.RestoreMetadata.ProjectUniqueName
                };
                actual.Should().BeEquivalentTo(expected);
            }
        }
Exemple #8
0
        public void PerformUpToDateCheck_WithProjectJsonProjects_ReturnsOnlyDirtyProjects()
        {
            using (var testDirectory = TestDirectory.Create())
            {
                var projectA = GetPackageSpec("A", testDirectory.Path);
                var projectB = GetPackageSpec("B", testDirectory.Path);
                var projectC = GetProjectJsonPackageSpec("C", testDirectory.Path);
                var projectD = GetProjectJsonPackageSpec("D", testDirectory.Path);

                // A => B & C
                projectA = projectA.WithTestProjectReference(projectB).WithTestProjectReference(projectC);
                DependencyGraphSpec dgSpec = ProjectTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD);

                var checker = new SolutionUpToDateChecker();

                // Preconditions, run 1st check
                var actual   = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance);
                var expected = GetUniqueNames(projectA, projectB, projectC, projectD);
                actual.Should().BeEquivalentTo(expected);
                var results = RunRestore(failedProjects: new HashSet <string>(), projectsWithWarnings: new HashSet <string>(), projectA, projectB, projectC, projectD);
                checker.SaveRestoreStatus(results);

                // Set-up, make C dirty.
                projectC = projectC.Clone();
                projectC.RestoreMetadata.ConfigFilePaths = new List <string>()
                {
                    "newFeed"
                };
                dgSpec = ProjectTestHelpers.GetDGSpecFromPackageSpecs(projectA, projectB, projectC, projectD);

                // Act & Assert
                actual   = checker.PerformUpToDateCheck(dgSpec, NullLogger.Instance);
                expected = GetUniqueNames(projectA, projectC);
                actual.Should().BeEquivalentTo(expected);
            }
        }
        public async Task RestoreAsync_WithProgressReporter_WithMultipleProjects_ProgressIsNotReportedForChangedProjetsOnly()
        {
            // Arrange
            using var pathContext = new SimpleTestPathContext();
            var settings         = Settings.LoadDefaultSettings(pathContext.SolutionRoot);
            var project1         = ProjectTestHelpers.GetPackageSpec(settings, projectName: "project1", rootPath: pathContext.SolutionRoot);
            var project2         = ProjectTestHelpers.GetPackageSpec(settings, projectName: "project2", rootPath: pathContext.SolutionRoot);
            var progressReporter = new Mock <IRestoreProgressReporter>();

            // Pre-Conditions
            IReadOnlyList <RestoreSummary> result = await DependencyGraphRestoreUtility.RestoreAsync(
                ProjectTestHelpers.GetDGSpecFromPackageSpecs(project1, project2),
                new DependencyGraphCacheContext(),
                new RestoreCommandProvidersCache(),
                cacheContextModifier : _ => { },
                sources : new SourceRepository[0],
                parentId : Guid.Empty,
                forceRestore : false,
                isRestoreOriginalAction : true,
                additionalMessages : null,
                progressReporter : progressReporter.Object,
                new TestLogger(),
                CancellationToken.None);

            // Pre-Conditions
            result.Should().HaveCount(2);
            foreach (RestoreSummary restoreSummary in result)
            {
                restoreSummary.Success.Should().BeTrue();
                restoreSummary.NoOpRestore.Should().BeFalse();
            }

            progressReporter.Verify(r =>
                                    r.StartProjectUpdate(
                                        It.Is <string>(e => e.Equals(project1.FilePath)),
                                        It.IsAny <IReadOnlyList <string> >()),
                                    Times.Once);
            progressReporter.Verify(r =>
                                    r.EndProjectUpdate(
                                        It.Is <string>(e => e.Equals(project1.FilePath)),
                                        It.IsAny <IReadOnlyList <string> >()),
                                    Times.Once);

            progressReporter.Verify(r =>
                                    r.StartProjectUpdate(
                                        It.Is <string>(e => e.Equals(project2.FilePath)),
                                        It.IsAny <IReadOnlyList <string> >()),
                                    Times.Once);
            progressReporter.Verify(r =>
                                    r.EndProjectUpdate(
                                        It.Is <string>(e => e.Equals(project2.FilePath)),
                                        It.IsAny <IReadOnlyList <string> >()),
                                    Times.Once);

            progressReporter.Verify(r =>
                                    r.StartProjectUpdate(
                                        It.IsAny <string>(),
                                        It.IsAny <IReadOnlyList <string> >()),
                                    Times.Exactly(2));
            progressReporter.Verify(r =>
                                    r.EndProjectUpdate(
                                        It.IsAny <string>(),
                                        It.IsAny <IReadOnlyList <string> >()),
                                    Times.Exactly(2));

            var secondaryProgressReporter = new Mock <IRestoreProgressReporter>();

            // Act
            result = await DependencyGraphRestoreUtility.RestoreAsync(
                ProjectTestHelpers.GetDGSpecFromPackageSpecs(project1.WithTestProjectReference(project2), project2),
                new DependencyGraphCacheContext(),
                new RestoreCommandProvidersCache(),
                cacheContextModifier : _ => { },
                sources : new SourceRepository[0],
                parentId : Guid.Empty,
                forceRestore : false,
                isRestoreOriginalAction : true,
                additionalMessages : null,
                progressReporter : secondaryProgressReporter.Object,
                new TestLogger(),
                CancellationToken.None);

            // Assert
            result.Should().HaveCount(2);
            var project1Summary = result.Single(e => e.InputPath.Equals(project1.FilePath));
            var project2Summary = result.Single(e => e.InputPath.Equals(project2.FilePath));

            project1Summary.Success.Should().BeTrue();
            project1Summary.NoOpRestore.Should().BeFalse();

            // One no-op
            project2Summary.Success.Should().BeTrue();
            project2Summary.NoOpRestore.Should().BeTrue();

            progressReporter.Verify(r =>
                                    r.StartProjectUpdate(
                                        It.Is <string>(e => e.Equals(project1.FilePath)),
                                        It.IsAny <IReadOnlyList <string> >()),
                                    Times.Once);
            progressReporter.Verify(r =>
                                    r.EndProjectUpdate(
                                        It.Is <string>(e => e.Equals(project1.FilePath)),
                                        It.IsAny <IReadOnlyList <string> >()),
                                    Times.Once);
        }
        public async Task RestoreAsync_WithProgressReporter_WhenProjectNoOps_ProgressIsNotReported()
        {
            // Arrange
            using var pathContext = new SimpleTestPathContext();
            var settings         = Settings.LoadDefaultSettings(pathContext.SolutionRoot);
            var packageSpec      = ProjectTestHelpers.GetPackageSpec(settings, projectName: "projectName", rootPath: pathContext.SolutionRoot);
            var dgSpec           = ProjectTestHelpers.GetDGSpecFromPackageSpecs(packageSpec);
            var progressReporter = new Mock <IRestoreProgressReporter>();

            // Pre-Conditions
            IReadOnlyList <RestoreSummary> result = await DependencyGraphRestoreUtility.RestoreAsync(
                dgSpec,
                new DependencyGraphCacheContext(),
                new RestoreCommandProvidersCache(),
                cacheContextModifier : _ => { },
                sources : new SourceRepository[0],
                parentId : Guid.Empty,
                forceRestore : false,
                isRestoreOriginalAction : true,
                additionalMessages : null,
                progressReporter : progressReporter.Object,
                new TestLogger(),
                CancellationToken.None);

            // Pre-Conditions
            result.Should().HaveCount(1);
            RestoreSummary restoreSummary = result[0];

            restoreSummary.Success.Should().BeTrue();
            restoreSummary.NoOpRestore.Should().BeFalse();

            progressReporter.Verify(r =>
                                    r.StartProjectUpdate(
                                        It.IsAny <string>(),
                                        It.IsAny <IReadOnlyList <string> >()),
                                    Times.Once);
            progressReporter.Verify(r =>
                                    r.EndProjectUpdate(
                                        It.IsAny <string>(),
                                        It.IsAny <IReadOnlyList <string> >()),
                                    Times.Once);

            var noopProgressReporter = new Mock <IRestoreProgressReporter>();

            // Act
            result = await DependencyGraphRestoreUtility.RestoreAsync(
                dgSpec,
                new DependencyGraphCacheContext(),
                new RestoreCommandProvidersCache(),
                cacheContextModifier : _ => { },
                sources : new SourceRepository[0],
                parentId : Guid.Empty,
                forceRestore : false,
                isRestoreOriginalAction : true,
                additionalMessages : null,
                progressReporter : noopProgressReporter.Object,
                new TestLogger(),
                CancellationToken.None);

            // Assert
            result.Should().HaveCount(1);
            restoreSummary = result[0];
            restoreSummary.Success.Should().BeTrue();
            restoreSummary.NoOpRestore.Should().BeTrue();

            noopProgressReporter.Verify(r =>
                                        r.StartProjectUpdate(
                                            It.IsAny <string>(),
                                            It.IsAny <IReadOnlyList <string> >()),
                                        Times.Never);
            noopProgressReporter.Verify(r =>
                                        r.EndProjectUpdate(
                                            It.IsAny <string>(),
                                            It.IsAny <IReadOnlyList <string> >()),
                                        Times.Never);
        }
Exemple #11
0
        public async Task GetUpdateActionsAsync_WithPackageReferenceProject_WhenUpdatingPackage_ReturnsCorrectActions()
        {
            const string projectName        = "a";
            string       projectId          = Guid.NewGuid().ToString();
            var          projectSystemCache = new ProjectSystemCache();

            using (TestDirectory testDirectory = TestDirectory.Create())
            {
                var    packageV1 = new SimpleTestPackageContext(packageId: "b", version: "1.0.0");
                var    packageV2 = new SimpleTestPackageContext(packageV1.Id, version: "2.0.0");
                string packageSourceDirectoryPath = Path.Combine(testDirectory, "packageSource");

                await SimpleTestPackageUtility.CreateFolderFeedV3Async(
                    packageSourceDirectoryPath,
                    PackageSaveMode.Defaultv3,
                    packageV1,
                    packageV2);

                var packageSource  = new PackageSource(packageSourceDirectoryPath);
                var packageSources = new List <PackageSource>()
                {
                    packageSource
                };

                Initialize(packageSources);

                string projectFullPath          = Path.Combine(testDirectory.Path, $"{projectName}.csproj");
                var    unconfiguredProject      = new Mock <UnconfiguredProject>();
                var    configuredProject        = new Mock <ConfiguredProject>();
                var    projectServices          = new Mock <ConfiguredProjectServices>();
                var    packageReferencesService = new Mock <IPackageReferencesService>();
                var    result = new Mock <IUnresolvedPackageReference>();

                unconfiguredProject.Setup(x => x.GetSuggestedConfiguredProjectAsync())
                .ReturnsAsync(configuredProject.Object);

                configuredProject.SetupGet(x => x.Services)
                .Returns(projectServices.Object);

                projectServices.SetupGet(x => x.PackageReferences)
                .Returns(packageReferencesService.Object);

                packageReferencesService.Setup(x => x.AddAsync(It.IsNotNull <string>(), It.IsNotNull <string>()))
                .ReturnsAsync(new AddReferenceResult <IUnresolvedPackageReference>(result.Object, added: true));

                var nuGetProjectServices = new Mock <INuGetProjectServices>();

                nuGetProjectServices.SetupGet(x => x.ScriptService)
                .Returns(Mock.Of <IProjectScriptHostService>());

                var project = new CpsPackageReferenceProject(
                    projectName: projectName,
                    projectUniqueName: projectFullPath,
                    projectFullPath: projectFullPath,
                    projectSystemCache,
                    unconfiguredProject.Object,
                    nuGetProjectServices.Object,
                    projectId);

                PackageSpec packageSpec = CreatePackageSpec(
                    project.ProjectName,
                    Path.Combine(testDirectory, "package.spec"));
                DependencyGraphSpec projectRestoreInfo = ProjectTestHelpers.GetDGSpecFromPackageSpecs(packageSpec);
                projectRestoreInfo.AddProject(packageSpec);
                var projectNames = new ProjectNames(
                    fullName: projectFullPath,
                    uniqueName: projectFullPath,
                    shortName: projectName,
                    customUniqueName: projectName,
                    projectId: projectId);
                projectSystemCache.AddProjectRestoreInfo(projectNames, projectRestoreInfo, Array.Empty <IAssetsLogMessage>());

                _solutionManager.NuGetProjects.Add(project);

                string[] projectIds         = new[] { projectId };
                string[] packageSourceNames = new[] { packageSource.Name };

                await PerformOperationAsync(async (projectManager) =>
                {
                    IReadOnlyList <ProjectAction> actions = await projectManager.GetInstallActionsAsync(
                        projectIds,
                        packageV1.Identity,
                        VersionConstraints.None,
                        includePrelease: true,
                        DependencyBehavior.Lowest,
                        packageSourceNames,
                        CancellationToken.None);

                    Assert.NotEmpty(actions);
                    Assert.Equal(1, actions.Count);

                    ProjectAction action = actions[0];

                    Assert.Equal(packageV1.Identity, action.PackageIdentity);
                    Assert.Equal(NuGetProjectActionType.Install, action.ProjectActionType);
                    Assert.Equal(projectId, action.ProjectId);

                    Assert.Equal(1, action.ImplicitActions.Count);

                    ImplicitProjectAction implicitAction = action.ImplicitActions[0];

                    Assert.Equal(packageV1.Identity, implicitAction.PackageIdentity);
                    Assert.Equal(NuGetProjectActionType.Install, implicitAction.ProjectActionType);

                    await projectManager.ExecuteActionsAsync(actions, CancellationToken.None);

                    AddPackageDependency(projectSystemCache, projectNames, packageSpec, packageV1);
                });

                await PerformOperationAsync(async (projectManager) =>
                {
                    IReadOnlyList <ProjectAction> actions = await projectManager.GetUpdateActionsAsync(
                        projectIds,
                        new[] { packageV2.Identity },
                        VersionConstraints.None,
                        includePrelease: true,
                        DependencyBehavior.Lowest,
                        packageSourceNames,
                        CancellationToken.None);

                    Assert.NotEmpty(actions);
                    Assert.Equal(1, actions.Count);

                    ProjectAction action = actions[0];

                    Assert.Equal(packageV2.Identity, action.PackageIdentity);
                    Assert.Equal(NuGetProjectActionType.Install, action.ProjectActionType);
                    Assert.Equal(projectId, action.ProjectId);

                    Assert.Equal(2, action.ImplicitActions.Count);

                    ImplicitProjectAction implicitAction = action.ImplicitActions[0];

                    Assert.Equal(packageV1.Identity, implicitAction.PackageIdentity);
                    Assert.Equal(NuGetProjectActionType.Uninstall, implicitAction.ProjectActionType);

                    implicitAction = action.ImplicitActions[1];

                    Assert.Equal(packageV2.Identity, implicitAction.PackageIdentity);
                    Assert.Equal(NuGetProjectActionType.Install, implicitAction.ProjectActionType);
                });
            }
        }