public void Can_Apply(string scenario, string json)
        {
            using (ApprovalResults.ForScenario(scenario))
            {
                // arrange
                var testFileUpgradeContext = new TestJsonBaseProjectUpgradeContext(json, null, null);
                // get target nuget packages for RC2, Preview1 tooling.
                var toolPackageMigrations = ProjectMigrator.GetToolPackageMigrationList(ToolingVersion.Preview2, testFileUpgradeContext);

                var sut = new MigrateToolPackages(toolPackageMigrations);

                // act
                sut.Apply(testFileUpgradeContext);
                testFileUpgradeContext.SaveChanges();

                // assert.
                var modifiedContents = testFileUpgradeContext.ModifiedProjectJsonContents;
                Approvals.VerifyJson(modifiedContents);
            }
        }
Ejemplo n.º 2
0
        protected virtual IList <IProjectUpgradeAction> GetPackagesUpgrades(IProjectUpgradeContext projectUpgradeContext, ReleaseVersion version)
        {
            var upgradeActions = new List <IProjectUpgradeAction>();


            //if (version == ReleaseVersion.RC2)
            //{
            // migrates specific nuget packages where their name has completely changed, and also adds new ones that the project may require.
            // this is currently described by a hardcoded list.
            ToolingVersion toolingVersion = ToolingVersion.Preview1;

            if (version == ReleaseVersion.RTM)
            {
                toolingVersion = ToolingVersion.Preview2;
            }
            var nugetPackagesToMigrate = ProjectMigrator.GetRc2DependencyPackageMigrationList(toolingVersion, projectUpgradeContext);
            var packageMigrationAction = new MigrateDependencyPackages(nugetPackagesToMigrate);

            upgradeActions.Add(packageMigrationAction);

            // renames microsoft.aspnet packages to be microsoft.aspnetcore.
            var renameAspNetPackagesAction = new RenameAspNetPackagesToAspNetCore();

            upgradeActions.Add(renameAspNetPackagesAction);

            // updates microsoft. packages to be rc2 version numbers.
            var updateMicrosoftPackageVersionNumbersAction = new UpgradeMicrosoftPackageVersionNumbers(version);

            upgradeActions.Add(updateMicrosoftPackageVersionNumbersAction);

            // renames "commands" to "tools"
            var renameCommandstoToolsAndClear = new RenameCommandsToTools();

            upgradeActions.Add(renameCommandstoToolsAndClear);

            // migrates old command packages to the new tool nuget packages.
            var toolPackagestoMigrate = GetToolPackageMigrationList(ToolingVersion.Preview1, projectUpgradeContext);
            var migrateToolPackages   = new MigrateToolPackages(toolPackagestoMigrate);

            upgradeActions.Add(migrateToolPackages);

            // }

            if (version == ReleaseVersion.RTM)
            {
                // migrates specific nuget packages where their name has completely changed, and also adds new ones that the project may require.
                // this is currently described by a hardcoded list.
                var nugetPackagesToMigrateRTM = ProjectMigrator.GetRtmDependencyPackageMigrationList(ToolingVersion.Preview2, projectUpgradeContext);
                var packageMigrationActionRTM = new MigrateDependencyPackages(nugetPackagesToMigrateRTM);
                upgradeActions.Add(packageMigrationActionRTM);

                // updates remaining microsoft rc2 packages to be rtm version numbers i.e 1.0.0 instead of 1.0.0-rc2-final
                var updateMicrosoftPackageVersionNumbersActionRtm = new UpgradeMicrosoftPackageVersionNumbers(version);
                upgradeActions.Add(updateMicrosoftPackageVersionNumbersActionRtm);


                // migrates old command packages to the new tool nuget packages.
                var toolPackagestoMigrateRtm = GetToolPackageMigrationList(ToolingVersion.Preview2, projectUpgradeContext);
                var migrateToolPackagesRtm   = new MigrateToolPackages(toolPackagestoMigrateRtm);
                upgradeActions.Add(migrateToolPackagesRtm);
            }

            return(upgradeActions);
        }