public void Can_Apply(string scenario, string json, string xproj)
        {
            using (ApprovalResults.ForScenario(scenario))
            {
                // arrange

                var upgradeActions = new List <IProjectUpgradeAction>();
                var testXProj      = VsProjectFactory.LoadTestProject(xproj);

                var testFileUpgradeContext = new TestJsonBaseProjectUpgradeContext(json, testXProj, null);

                // updates the sdk version in global json.
                var runtimeUpgradeAction = new MigrateProjectImportsFromDnxToDotNet();
                upgradeActions.Add(runtimeUpgradeAction);

                // Apply these actions to the project.json file.
                foreach (var upgradeAction in upgradeActions)
                {
                    upgradeAction.Apply(testFileUpgradeContext);
                }

                // save the changes.
                testFileUpgradeContext.SaveChanges();

                var projContents = VsProjectHelper.ToString(testFileUpgradeContext.VsProjectFile);
                Approvals.VerifyXml(projContents);


                // assert.
                //var modifiedContents = testFileUpgradeContext.ModifiedJsonContents;
                //Approvals.VerifyJson(modifiedContents);

                // Approvals.VerifyAll();
            }
        }
Example #2
0
        private IEnumerable <IProjectUpgradeAction> GetSchemaUpgrades(ProjectMigrationOptions options, BaseProjectUpgradeContext context)
        {
            var upgradeActions = new List <IProjectUpgradeAction>();

            //if (options.PackagesVersion == ReleaseVersion.)
            //{
            // upgrades the compilation options section.
            var compilationOptionsUpgradeAction = new UpgradeCompilationOptionsJson();

            upgradeActions.Add(compilationOptionsUpgradeAction);

            // moves things to packOptions.
            var upgradePackOptions = new UpgradePackOptions();

            upgradeActions.Add(upgradePackOptions);

            // moves content to the new packOptions and buildOptions / copyToOutput
            var moveContent = new MoveContentToNewOptions();

            upgradeActions.Add(moveContent);

            // moves resources to buildOptions.
            var moveResources = new MoveResourcesToBuildOptions();

            upgradeActions.Add(moveResources);

            // move compile to build options.
            var moveCompileToBuildOptions = new MoveCompileToBuildOptions();

            upgradeActions.Add(moveCompileToBuildOptions);

            // move exclude to build options
            var moveExcludeToBuildOptions = new MoveExcludeToBuildOptions();

            upgradeActions.Add(moveExcludeToBuildOptions);

            // moves things to publishOptions.
            var upgradePublishOptions = new UpgradePublishOptions();

            upgradeActions.Add(upgradePublishOptions);

            // includes appSettings.Json files in copyToOutput
            var includeAppSettingsFilesInCopyToOutput = new IncludeAppSettingsFilesInCopyToOutput();

            upgradeActions.Add(includeAppSettingsFilesInCopyToOutput);

            // includes Views folder in copyToOutput
            var includeViewsFolderInCopyToOutput = new IncludeViewsFolderInCopyToOutput();

            upgradeActions.Add(includeViewsFolderInCopyToOutput);

            // renames the old dnx4YZ TFM's to be the net4YZ Tfm's.
            var frameworksUpgradeAction = new MigrateDnxFrameworksToNetFramework452Json();

            upgradeActions.Add(frameworksUpgradeAction);

            // upgrades xproj file, by updating old dnx imports to new dotnet ones.
            var xprojImportsUpgrade = new MigrateProjectImportsFromDnxToDotNet();

            upgradeActions.Add(xprojImportsUpgrade);

            // updates xproj baseintermediate output path
            var xprojUpdateBaseIntermediateOutputPath = new UpdateBaseIntermediateOutputPath();

            upgradeActions.Add(xprojUpdateBaseIntermediateOutputPath);

            // updates xproj targetFramework
            var xprojUpdateTargetFramework = new SetTargetFrameworkVersion(options.TargetFrameworkVersionForXprojFile);

            upgradeActions.Add(xprojUpdateTargetFramework);

            // updates launch settings
            var updateLaunchSettings = new UpdateLaunchSettings();

            upgradeActions.Add(updateLaunchSettings);
            // }

            //  if (options.PackagesVersion == ReleaseVersion.RTM)
            //  {

            // NONE NECESSAERY.
            //  }



            return(upgradeActions);
        }