Ejemplo n.º 1
0
        public MigrationReport Migrate(MigrationSettings rootSettings, bool skipProjectReferences = false)
        {
            if (rootSettings == null)
            {
                throw new ArgumentNullException();
            }

            // Try to read the project dependencies, ignore an unresolved exception for now
            MigrationRuleInputs             rootInputs          = ComputeMigrationRuleInputs(rootSettings);
            IEnumerable <ProjectDependency> projectDependencies = null;

            var tempMSBuildProjectTemplate = rootSettings.CloneMSBuildProjectTemplate();

            try
            {
                // Verify up front so we can prefer these errors over an unresolved project dependency
                VerifyInputs(rootInputs, rootSettings);

                projectDependencies = ResolveTransitiveClosureProjectDependencies(
                    rootSettings.ProjectDirectory,
                    rootSettings.ProjectXProjFilePath);
            }
            catch (MigrationException e)
            {
                return(new MigrationReport(
                           new List <ProjectMigrationReport>
                {
                    new ProjectMigrationReport(
                        rootSettings.ProjectDirectory,
                        rootInputs?.DefaultProjectContext.GetProjectName(),
                        new List <MigrationError> {
                        e.Error
                    },
                        null)
                }));
            }

            var projectMigrationReports = new List <ProjectMigrationReport>();

            projectMigrationReports.Add(MigrateProject(rootSettings));

            if (skipProjectReferences)
            {
                return(new MigrationReport(projectMigrationReports));
            }

            foreach (var project in projectDependencies)
            {
                var projectDir = Path.GetDirectoryName(project.ProjectFilePath);
                var settings   = new MigrationSettings(projectDir,
                                                       projectDir,
                                                       rootSettings.SdkPackageVersion,
                                                       tempMSBuildProjectTemplate);
                MigrateProject(settings);
                projectMigrationReports.Add(MigrateProject(settings));
            }

            return(new MigrationReport(projectMigrationReports));
        }
Ejemplo n.º 2
0
 public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
 {
     foreach (var rule in Rules)
     {
         MigrationTrace.Instance.WriteLine($"{nameof(DefaultMigrationRuleSet)}: Executing migration rule {rule.GetType().Name}");
         rule.Apply(migrationSettings, migrationRuleInputs);
     }
 }
Ejemplo n.º 3
0
        public bool IsMigrated(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            var outputName = migrationRuleInputs.DefaultProjectContext.GetProjectName();

            var outputProject = Path.Combine(migrationSettings.OutputDirectory, outputName + ".csproj");

            return(File.Exists(outputProject));
        }
Ejemplo n.º 4
0
 private void VerifyInputs(
     MigrationRuleInputs migrationRuleInputs,
     MigrationSettings migrationSettings,
     out List <string> warningMessages
     )
 {
     VerifyProject(migrationRuleInputs.ProjectContexts, migrationSettings.ProjectDirectory, out warningMessages);
 }
Ejemplo n.º 5
0
 public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
 {
     foreach (var rule in Rules)
     {
         MigrationTrace.Instance.WriteLine(string.Format(LocalizableStrings.ExecutingMigrationRule, nameof(DefaultMigrationRuleSet), rule.GetType().Name));
         rule.Apply(migrationSettings, migrationRuleInputs);
     }
 }
Ejemplo n.º 6
0
        public bool IsMigrated(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            var outputName = Path.GetFileNameWithoutExtension(
                migrationRuleInputs.DefaultProjectContext.GetOutputPaths("_").CompilationFiles.Assembly);

            var outputProject = Path.Combine(migrationSettings.OutputDirectory, outputName + ".csproj");

            return(File.Exists(outputProject));
        }
Ejemplo n.º 7
0
 private void VerifyInputs(MigrationRuleInputs migrationRuleInputs, MigrationSettings migrationSettings)
 {
     VerifyProject(migrationRuleInputs.ProjectContexts, migrationSettings.ProjectDirectory);
 }