Exemple #1
0
        /// <summary>
        /// Migrates the project.
        /// </summary>
        /// <param name="options">migration options.</param>
        /// <param name="additionalMigrations">any additional migrations to apply.</param>
        public void Apply(ProjectMigrationOptions options, IList <IProjectUpgradeAction> additionalMigrations = null)
        {
            List <IProjectUpgradeAction> migrations = new List <IProjectUpgradeAction>();
            var context = this.Context;

            //if (options.UpgradeToPreview1)
            //{
            migrations.AddRange(GetSchemaUpgrades(options, context));
            //}
            // if (options.UpgradePackagesToRc2)
            // {
            migrations.AddRange(GetPackagesUpgrades(context, options.PackagesVersion));
            // }

            if (options.AddNetCoreTargetForApplications)
            {
                //// Makes applications target .netcoreapp.
                var addNetCoreApp = new AddNetCoreFrameworkToApplications("1.0.0-rc2-3002702");
                migrations.Add(addNetCoreApp);
            }
            if (options.AddNetStandardTargetForLibraries)
            {
                // Adds the netStandard framework, with specified version of NETStandard.Library dependency, to any library project.json's.
                var addNetStandard = new AddNetStandardFrameworkToLibrariesJson("netstandard1.5", "1.5.0-rc2-24027");
                migrations.Add(addNetStandard);
            }


            // upgrade to preview 2
            //if (options.ToolingVersion)
            //{
            //    migrations.AddRange(GetSchemaUpgrades(options, context));
            //}
            //if (options.PackagesVersion == ReleaseVersion.RTM)
            //{
            //    migrations.AddRange(GetPackagesUpgrades(context));
            //}


            // additional migrations to apply
            if (additionalMigrations != null && additionalMigrations.Any())
            {
                migrations.AddRange(additionalMigrations);
            }

            this.Apply(migrations);
        }
Exemple #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);
        }