public List <DependencyPackageMigrationInfo> GetPackageMigrations(ToolingVersion targetToolingVersion, IProjectUpgradeContext projectContext)
        {
            var    list           = new List <DependencyPackageMigrationInfo>();
            string toolingVersion = targetToolingVersion.ToString().ToLowerInvariant();

            var package = new DependencyPackageMigrationInfo("Microsoft.Extensions.Configuration.FileExtensions", "1.0.0-rc2-final");

            package.OldNames.Add("Microsoft.Extensions.Configuration.FileProviderExtensions");
            list.Add(package);


            // If Microsoft.Extensions.PlatformAbstractions package is referenced, it was split out in RC2 so add the new package as well, in case you were using classes from it.
            if (projectContext.ToProjectJsonWrapper().HasDependency("Microsoft.Extensions.PlatformAbstractions"))
            {
                package = new DependencyPackageMigrationInfo("Microsoft.Extensions.DependencyModel", "1.0.0-rc2-final");
                package.MigrationAction = PackageMigrationAction.AddOrUpdate;
                list.Add(package);
            }

            // only add the following new nuget packlages if the project is a web project. We use a heuristic - if MVC is there as a dependency then its a web project.
            if (projectContext.ToProjectJsonWrapper().IsMvcProject())
            {
                package = new DependencyPackageMigrationInfo("Microsoft.Extensions.Options.ConfigurationExtensions", $"1.0.0-rc2-final");
                package.MigrationAction = PackageMigrationAction.AddOrUpdate;
                list.Add(package);
            }



            return(list);
        }
        public List <ToolPackageMigrationInfo> GetPackageMigrations(ToolingVersion targetToolingVersion, IProjectUpgradeContext projectContext)
        {
            var    list           = new List <ToolPackageMigrationInfo>();
            string toolingVersion = targetToolingVersion.ToString().ToLowerInvariant();

            // Updates the old web command if it is found, to be the new tool.
            var package = new ToolPackageMigrationInfo("Microsoft.AspNetCore.Server.IISIntegration.Tools", $"1.0.0-{toolingVersion}-final");

            package.OldNames.Add("web");
            package.Imports.Add("portable-net45+win8+dnxcore50");
            package.MigrationAction = PackageMigrationAction.Update;
            list.Add(package);


            // Adds / updates the user secrets tool - if the project.json has a userSecretsId present.
            if (projectContext.ProjectJsonObject["userSecretsId"] != null)
            {
                package = new ToolPackageMigrationInfo("Microsoft.Extensions.SecretManager.Tools", $"1.0.0-{toolingVersion}-final");
                package.Imports.Add("portable-net45+win8+dnxcore50");
                package.MigrationAction = PackageMigrationAction.AddOrUpdate;
                list.Add(package);
            }

            // Updates the old ef command if it is found, to be the new tool.
            package = new ToolPackageMigrationInfo("Microsoft.EntityFrameworkCore.Tools", $"1.0.0-{toolingVersion}-final");
            package.OldNames.Add("ef");
            package.Imports.Add("portable-net45+win8+dnxcore50");
            package.Imports.Add("portable-net45+win8");
            package.MigrationAction = PackageMigrationAction.Update;
            list.Add(package);


            // only add the razor tools tool if project allready references razor tools package as a dependency (either as new or old name) in case we havent updated it yet)
            if (projectContext.ToProjectJsonWrapper().HasDependency("Microsoft.AspNetCore.Razor.Tools") ||
                projectContext.ToProjectJsonWrapper().HasDependency("Microsoft.AspNet.Tooling.Razor"))
            {
                package = new ToolPackageMigrationInfo("Microsoft.AspNetCore.Razor.Tools", $"1.0.0-{toolingVersion}-final");
                package.Imports.Add("portable-net45+win8+dnxcore50");
                package.MigrationAction = PackageMigrationAction.AddOrUpdate;
                list.Add(package);
            }

            // only add the web code generation tools to the project if its a web project. We use a heuristic - if MVC is there as a dependency then its a web project.
            if (projectContext.ToProjectJsonWrapper().IsMvcProject())
            {
                package = new ToolPackageMigrationInfo("Microsoft.VisualStudio.Web.CodeGeneration.Tools", $"1.0.0-{toolingVersion}-final");
                package.Imports.Add("portable-net45+win8+dnxcore50");
                package.Imports.Add("portable-net45+win8");
                package.MigrationAction = PackageMigrationAction.AddOrUpdate;
                list.Add(package);
            }


            return(list);
        }
コード例 #3
0
        public void Apply(IProjectUpgradeContext fileUpgradeContext)
        {
            JObject projectJsonObject = fileUpgradeContext.ProjectJsonObject;
            JObject frameworks        = (JObject)projectJsonObject["frameworks"];

            //_oldFrameworks = frameworks.DeepClone();

            // dnx451
            RenameFramework(frameworks, "dnx", "net452");
            RenameFramework(frameworks, "dnx45", "net452");
            RenameFramework(frameworks, "dnx451", "net452");
            RenameFramework(frameworks, "dnx452", "net452");

            // dnxCore
            var dnxCore50 = frameworks.Property("dnxcore50");

            if (dnxCore50 != null)
            {
                dnxCore50.Remove();

                var projWrapper = fileUpgradeContext.ToProjectJsonWrapper();
                var projType    = projWrapper.GetProjectType();
                if (projType == ProjectType.Library)
                {
                    projWrapper.AddNetStandardFramework(NetStandardLibraryVersion, NetStandardTfm);
                }
                else if (projType == ProjectType.Application)
                {
                    projWrapper.AddNetCoreAppFramework(NetCoreAppVersion, NetCoreAppTfmName);
                }
            }
        }
 public void Apply(IProjectUpgradeContext fileUpgradeContext)
 {
     if (fileUpgradeContext.VsProjectFile != null)
     {
         bool isWebProject = fileUpgradeContext.ToProjectJsonWrapper().IsMvcProject();
         UpgradeDnxProjectToDotNet(fileUpgradeContext.VsProjectFile, isWebProject);
     }
 }
        public void Apply(IProjectUpgradeContext fileUpgradeContext)
        {
            var projectWrapper = fileUpgradeContext.ToProjectJsonWrapper();
            var projType       = projectWrapper.GetProjectType();

            if (projType == ProjectType.Library)
            {
                projectWrapper.AddNetStandardFramework(_netStandardLibraryVersion, _netStandardTfm);
            }
        }
        public void Apply(IProjectUpgradeContext fileUpgradeContext)
        {
            var projectJsonWrapper = fileUpgradeContext.ToProjectJsonWrapper();

            if (projectJsonWrapper.IsMvcProject())
            {
                var items = new JArray();
                items.Add("Views/**");

                projectJsonWrapper.IncludeInCopyToOutput(items);
            }
        }
        public void Apply(IProjectUpgradeContext fileUpgradeContext)
        {
            JObject projectJsonObject = fileUpgradeContext.ProjectJsonObject;
            JObject frameworks        = (JObject)projectJsonObject["frameworks"];

            var projWrapper = fileUpgradeContext.ToProjectJsonWrapper();
            var projType    = projWrapper.GetProjectType();

            if (projType == ProjectType.Application)
            {
                if (!projWrapper.HasFramework(_netCoreAppTfmName))
                {
                    projWrapper.AddNetCoreAppFramework(_netCoreAppVersion, _netCoreAppTfmName);
                }
            }
        }
コード例 #8
0
        public void Apply(IProjectUpgradeContext fileUpgradeContext)
        {
            JObject projectJsonObject = fileUpgradeContext.ProjectJsonObject;

            // get appsettings json files.
            var appSettingsFileNames =
                fileUpgradeContext.JsonFiles.Where(a => a.Name().ToLowerInvariant().StartsWith("appsettings")).ToArray();
            // for each one, include it in the publishOptions and the copytooutput.

            JArray copyToOutputArray = new JArray();

            foreach (var appSettingsFile in appSettingsFileNames)
            {
                copyToOutputArray.Add(appSettingsFile.Name());
            }

            var projectJsonWrapper = fileUpgradeContext.ToProjectJsonWrapper();

            projectJsonWrapper.IncludeInCopyToOutput(copyToOutputArray);
        }
コード例 #9
0
        public void Apply(IProjectUpgradeContext fileUpgradeContext)
        {
            JObject projectJsonObject = fileUpgradeContext.ProjectJsonObject;

            //  JArray exclude = (JArray)projectJsonObject["exclude"];
            // JArray publishExclude = (JArray)projectJsonObject["publishExclude"];

            projectJsonObject.Remove("exclude");
            projectJsonObject.Remove("publishExclude");

            JArray includeArray = new JArray();

            if (fileUpgradeContext.ToProjectJsonWrapper().IsMvcProject())
            {
                // add default publishing options
                includeArray.Add("wwwroot");
                includeArray.Add("web.config");
            }

            var appSettingsFileNames = fileUpgradeContext.JsonFiles.Where(a => a.Name().ToLowerInvariant().StartsWith("appsettings")).ToArray();

            foreach (var item in appSettingsFileNames)
            {
                includeArray.Add(item.Name());
            }

            //includeArray.Add("Views");
            //   includeArray.Add("appSettings.json");

            var publishOptions = new JObject(new JProperty("include", includeArray));

            projectJsonObject["publishOptions"] = publishOptions;

            //              "publishOptions": {
            //                  "include": [
            //                    "wwwroot",
            //                    "appsettings.json",
            //                    "web.config"
            //]
            //  },
        }
        public List <DependencyPackageMigrationInfo> GetPackageMigrations(ToolingVersion targetToolingVersion, IProjectUpgradeContext projectContext)
        {
            var    list           = new List <DependencyPackageMigrationInfo>();
            string toolingVersion = ToolingVersion.Preview1.ToString().ToLowerInvariant();

            // aspnet packages
            var package = new DependencyPackageMigrationInfo("Microsoft.AspNetCore.Identity.EntityFrameworkCore", "1.0.0-rc2-final");

            package.OldNames.Add("Microsoft.AspNet.Identity.EntityFramework");
            list.Add(package);

            package = new DependencyPackageMigrationInfo("Microsoft.AspNetCore.Server.IISIntegration", "1.0.0-rc2-final");
            package.OldNames.Add("Microsoft.AspNet.IISPlatformHandler");
            list.Add(package);

            package = new DependencyPackageMigrationInfo("Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore", "1.0.0-rc2-final");
            package.OldNames.Add("Microsoft.AspNet.Diagnostics.Entity");
            list.Add(package);


            package      = new DependencyPackageMigrationInfo("Microsoft.AspNetCore.Razor.Tools", $"1.0.0-{toolingVersion}-final");
            package.Type = PackageType.Build;
            package.OldNames.Add("Microsoft.AspNet.Tooling.Razor");
            list.Add(package);

            var projectWrapper = projectContext.ToProjectJsonWrapper();

            // only add the following new nuget packlages if the project is a web project. We use a heuristic - if MVC is there as a dependency then its a web project.
            if (projectWrapper.IsMvcProject())
            {
                package                 = new DependencyPackageMigrationInfo("Microsoft.VisualStudio.Web.CodeGeneration.Tools", $"1.0.0-{toolingVersion}-final");
                package.Type            = PackageType.Build;
                package.MigrationAction = PackageMigrationAction.AddOrUpdate;
                list.Add(package);

                // ensure Microsoft.AspNetCore.Diagnostics is brought in
                package = new DependencyPackageMigrationInfo("Microsoft.AspNetCore.Diagnostics", "1.0.0-rc2-final");
                package.OldNames.Add("Microsoft.AspNet.Diagnostics");
                package.MigrationAction = PackageMigrationAction.AddOrUpdate;
                list.Add(package);
            }

            package = new DependencyPackageMigrationInfo("Microsoft.VisualStudio.Web.CodeGenerators.Mvc", $"1.0.0-{toolingVersion}-final");
            package.OldNames.Add("Microsoft.Extensions.CodeGenerators.Mvc");
            package.Type = PackageType.Build;
            list.Add(package);


            package = new DependencyPackageMigrationInfo("Microsoft.ApplicationInsights.AspNetCore", "1.0.0-rc2-final");
            package.OldNames.Add("Microsoft.ApplicationInsights.AspNet");
            list.Add(package);

            // Ensure following package is present if depending on IISPlatformHandler
            if (projectWrapper.HasDependency("Microsoft.AspNet.IISPlatformHandler") ||
                projectWrapper.HasDependency("Microsoft.AspNetCore.Server.IISIntegration"))
            {
                package = new DependencyPackageMigrationInfo("Microsoft.AspNetCore.Hosting", $"1.0.0-rc2-final");
                package.MigrationAction = PackageMigrationAction.AddOrUpdate;
                list.Add(package);
            }

            // remove Microsoft.Dnx.Runtime
            package = new DependencyPackageMigrationInfo("Microsoft.Dnx.Runtime", "1.0.0-rc1-final");
            package.MigrationAction = PackageMigrationAction.Remove;
            list.Add(package);


            return(list);
        }