public void TFMSpecificProjectDependenciesAreMigratedToProjectReferenceUnderConditionItemGroup()
        {
            var solutionDirectory = TestAssets.Get("TestAppWithLibraryUnderTFM")
                                    .CreateInstance(callingMethod: "p")
                                    .WithSourceFiles()
                                    .Root.FullName;

            var appDirectory = Path.Combine(solutionDirectory, "TestApp");

            var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp11);
            var mockProj       = ProjectRootElement.Create();
            var testSettings   = MigrationSettings.CreateMigrationSettingsTestHook(appDirectory, appDirectory, mockProj, null);
            var testInputs     = new MigrationRuleInputs(new[] { projectContext }, mockProj, mockProj.AddItemGroup(),
                                                         mockProj.AddPropertyGroup());

            new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);

            var projectReferences = mockProj.Items.Where(item => item.ItemType.Equals("ProjectReference", StringComparison.Ordinal));

            projectReferences.Count().Should().Be(1);

            var projectReference = projectReferences.First();

            projectReference.Include.Should().Be(Path.Combine("..", "TestLibrary", "TestLibrary.csproj"));
            projectReference.Parent.Condition.Should().Be(" '$(TargetFramework)' == 'netcoreapp1.1' ");
        }
        private ProjectRootElement MigrateProject(
            string solution,
            string project,
            NuGetFramework targetFramework)
        {
            var solutionDirectory = TestAssets.Get(solution)
                                    .CreateInstance(callingMethod: "p")
                                    .WithSourceFiles()
                                    .Root.FullName;

            var appDirectory = Path.Combine(solutionDirectory, project);

            var projectContext = ProjectContext.Create(appDirectory, targetFramework);
            var mockProj       = ProjectRootElement.Create();
            var testSettings   = MigrationSettings.CreateMigrationSettingsTestHook(appDirectory, appDirectory, mockProj, null);
            var testInputs     = new MigrationRuleInputs(new[] { projectContext }, mockProj, mockProj.AddItemGroup(),
                                                         mockProj.AddPropertyGroup());

            new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);

            var s = mockProj.Items.Select(p => $"ItemType = {p.ItemType}, Include = {p.Include}");

            Console.WriteLine(string.Join(Environment.NewLine, s));

            return(mockProj);
        }
        public void If_a_project_dependency_is_present_DesignTimeAutoUnify_and_AutoUnify_are_present()
        {
            var solutionDirectory =
                TestAssetsManager.CreateTestInstance("TestAppWithLibrary", callingMethod: "p").Path;

            var appDirectory = Path.Combine(solutionDirectory, "TestApp");
            var libDirectory = Path.Combine(solutionDirectory, "TestLibrary");

            var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
            var mockProj       = ProjectRootElement.Create();
            var testSettings   = new MigrationSettings(appDirectory, appDirectory, "1.0.0", mockProj);
            var testInputs     = new MigrationRuleInputs(new[] { projectContext }, mockProj, mockProj.AddItemGroup(),
                                                         mockProj.AddPropertyGroup());

            new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);

            var autoUnify = mockProj.Properties.Where(p => p.Name == "AutoUnify");

            autoUnify.Count().Should().Be(1);
            autoUnify.First().Value.Should().Be("true");

            var designTimeAutoUnify = mockProj.Properties.Where(p => p.Name == "DesignTimeAutoUnify");

            designTimeAutoUnify.Count().Should().Be(1);
            designTimeAutoUnify.First().Value.Should().Be("true");
        }
        private void AddProjectTypeSpecificDependencies(
            MigrationRuleInputs migrationRuleInputs,
            MigrationSettings migrationSettings,
            ProjectItemGroupElement noFrameworkPackageReferenceItemGroup)
        {
            var type = migrationRuleInputs.DefaultProjectContext.ProjectFile.GetProjectType();

            switch (type)
            {
            case ProjectType.Web:
                _transformApplicator.Execute(
                    SdkPackageDependencyTransform.Transform(
                        new PackageDependencyInfo
                {
                    Name          = PackageConstants.WebSdkPackageName,
                    Version       = migrationSettings.SdkPackageVersion,
                    PrivateAssets = "All"
                }),
                    noFrameworkPackageReferenceItemGroup,
                    mergeExisting: false);
                break;

            default:
                break;
            }
        }
示例#5
0
        public void MigratingCoreAndDesktopTFMsAddsRuntimeIdentifierWithWin7x86ConditionOnAllFullFrameworksWhenNoRuntimesExistAlready()
        {
            var testDirectory = Temp.CreateDirectory().Path;
            var testPJ        = new ProjectJsonBuilder(TestAssets)
                                .FromTestAssetBase("PJAppWithMultipleFrameworks")
                                .SaveToDisk(testDirectory);

            var projectContexts = ProjectContext.CreateContextForEachFramework(testDirectory);
            var mockProj        = ProjectRootElement.Create();

            var migrationSettings = MigrationSettings.CreateMigrationSettingsTestHook(testDirectory, testDirectory, mockProj);
            var migrationInputs   = new MigrationRuleInputs(
                projectContexts,
                mockProj,
                mockProj.AddItemGroup(),
                mockProj.AddPropertyGroup());

            new MigrateTFMRule().Apply(migrationSettings, migrationInputs);

            mockProj.Properties.Count(p => p.Name == "RuntimeIdentifier").Should().Be(1);
            var runtimeIdentifier = mockProj.Properties.First(p => p.Name == "RuntimeIdentifier");

            runtimeIdentifier.Value.Should().Be("win7-x86");
            runtimeIdentifier.Condition.Should().Be(" '$(TargetFramework)' == 'net20' OR '$(TargetFramework)' == 'net35' OR '$(TargetFramework)' == 'net40' OR '$(TargetFramework)' == 'net461' ");
        }
示例#6
0
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            bool shouldRenameOldProject = PathsAreEqual(migrationSettings.OutputDirectory, migrationSettings.ProjectDirectory);

            if (!shouldRenameOldProject && File.Exists(Path.Combine(migrationSettings.OutputDirectory, "project.json")))
            {
                // TODO: should there be a setting to overwrite anything in output directory?
                throw new Exception("Existing project.json found in output directory.");
            }

            var sourceProjectFile      = Path.Combine(migrationSettings.ProjectDirectory, "project.json");
            var destinationProjectFile = Path.Combine(migrationSettings.OutputDirectory, "project.json");

            if (shouldRenameOldProject)
            {
                var renamedProjectFile = Path.Combine(migrationSettings.ProjectDirectory, "project.migrated.json");
                File.Move(sourceProjectFile, renamedProjectFile);
                sourceProjectFile = renamedProjectFile;
            }

            var json = CreateDestinationProjectFile(sourceProjectFile, destinationProjectFile);

            InjectSdkReference(json, ConstantPackageNames.CSdkPackageName, migrationSettings.SdkPackageVersion);
            RemoveRuntimesNode(json);

            File.WriteAllText(destinationProjectFile, json.ToString());
        }
示例#7
0
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            var csproj         = migrationRuleInputs.OutputMSBuildProject;
            var projectContext = migrationRuleInputs.DefaultProjectContext;

            var propertyGroup = _configurationPropertyGroup ?? migrationRuleInputs.CommonPropertyGroup;
            var itemGroup     = _configurationItemGroup ?? migrationRuleInputs.CommonItemGroup;

            var compilerOptions = projectContext.ProjectFile.GetCompilerOptions(null, null);

            // If we're in a configuration, we need to be careful not to overwrite values from BuildOptions
            // without a configuration
            if (_configurationBuildOptions == null)
            {
                CleanExistingProperties(csproj);

                PerformPropertyAndItemMappings(
                    compilerOptions,
                    propertyGroup,
                    itemGroup,
                    _transformApplicator,
                    migrationSettings.ProjectDirectory);
            }
            else
            {
                PerformConfigurationPropertyAndItemMappings(
                    compilerOptions,
                    _configurationBuildOptions,
                    propertyGroup,
                    itemGroup,
                    _transformApplicator,
                    migrationSettings.ProjectDirectory);
            }
        }
        public void Migrating_Single_TFM_project_Populates_TargetFrameworks_with_short_tfm()
        {
            var testDirectory = Temp.CreateDirectory().Path;
            var testPJ        = new ProjectJsonBuilder(TestAssetsManager)
                                .FromTestAssetBase("TestAppWithRuntimeOptions")
                                .WithCustomProperty("buildOptions", new Dictionary <string, string>
            {
                { "emitEntryPoint", "false" }
            })
                                .SaveToDisk(testDirectory);

            var projectContext = ProjectContext.Create(testDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
            var mockProj       = ProjectRootElement.Create();

            // Run BuildOptionsRule
            var migrationSettings = new MigrationSettings(testDirectory, testDirectory, "1.0.0", mockProj);
            var migrationInputs   = new MigrationRuleInputs(
                new[] { projectContext },
                mockProj,
                mockProj.AddItemGroup(),
                mockProj.AddPropertyGroup());

            new MigrateTFMRule().Apply(migrationSettings, migrationInputs);

            mockProj.Properties.Count(p => p.Name == "TargetFrameworks").Should().Be(1);
            mockProj.Properties.First(p => p.Name == "TargetFrameworks").Value.Should().Be("netcoreapp1.0");
        }
示例#9
0
        private void MigrateConfiguration(
            string configuration,
            NuGetFramework framework,
            MigrationSettings migrationSettings,
            MigrationRuleInputs migrationRuleInputs)
        {
            var csproj = migrationRuleInputs.OutputMSBuildProject;

            var propertyGroup = CreatePropertyGroupAtEndOfProject(csproj);
            var itemGroup     = CreateItemGroupAtEndOfProject(csproj);

            var configurationCondition = $" '$(Configuration)' == '{configuration}' ";

            if (framework != null)
            {
                configurationCondition +=
                    $" and '$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion)' == '{framework.DotNetFrameworkName}' ";
            }
            propertyGroup.Condition = configurationCondition;
            itemGroup.Condition     = configurationCondition;

            new MigrateBuildOptionsRule(configuration, framework, propertyGroup, itemGroup)
            .Apply(migrationSettings, migrationRuleInputs);

            propertyGroup.RemoveIfEmpty();
            itemGroup.RemoveIfEmpty();
        }
        public void Migrating_netcoreapp_project_Does_not_populate_TargetFrameworkIdentifier_and_TargetFrameworkVersion()
        {
            var testDirectory = Temp.CreateDirectory().Path;
            var testPJ        = new ProjectJsonBuilder(TestAssetsManager)
                                .FromTestAssetBase("TestAppWithRuntimeOptions")
                                .WithCustomProperty("buildOptions", new Dictionary <string, string>
            {
                { "emitEntryPoint", "false" }
            })
                                .SaveToDisk(testDirectory);

            var projectContext = ProjectContext.Create(testDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
            var mockProj       = ProjectRootElement.Create();

            var migrationSettings = new MigrationSettings(testDirectory, testDirectory, mockProj);
            var migrationInputs   = new MigrationRuleInputs(
                new[] { projectContext },
                mockProj,
                mockProj.AddItemGroup(),
                mockProj.AddPropertyGroup());

            new MigrateTFMRule().Apply(migrationSettings, migrationInputs);

            mockProj.Properties.Count(p => p.Name == "TargetFrameworkIdentifier").Should().Be(0);
            mockProj.Properties.Count(p => p.Name == "TargetFrameworkVersion").Should().Be(0);
        }
示例#11
0
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            var projectContext = migrationRuleInputs.DefaultProjectContext;
            var configurations = projectContext.ProjectFile.GetConfigurations().ToList();

            var frameworks = new List <NuGetFramework>();

            frameworks.Add(null);
            frameworks.AddRange(projectContext.ProjectFile.GetTargetFrameworks().Select(t => t.FrameworkName));

            if (!configurations.Any())
            {
                return;
            }

            var frameworkConfigurationCombinations = frameworks.SelectMany(f => configurations, Tuple.Create);

            foreach (var entry in frameworkConfigurationCombinations)
            {
                var framework     = entry.Item1;
                var configuration = entry.Item2;

                MigrateConfiguration(configuration, framework, migrationSettings, migrationRuleInputs);
            }
        }
        public void Migrating_Single_TFM_project_Populates_TargetFramework()
        {
            var testDirectory = Temp.CreateDirectory().Path;
            var testPJ        = new ProjectJsonBuilder(TestAssetsManager)
                                .FromTestAssetBase("TestAppWithRuntimeOptions")
                                .WithCustomProperty("buildOptions", new Dictionary <string, string>
            {
                { "emitEntryPoint", "false" }
            })
                                .SaveToDisk(testDirectory);

            var projectContexts = ProjectContext.CreateContextForEachFramework(testDirectory);
            var mockProj        = ProjectRootElement.Create();

            // Run BuildOptionsRule
            var migrationSettings = new MigrationSettings(testDirectory, testDirectory, mockProj);
            var migrationInputs   = new MigrationRuleInputs(
                projectContexts,
                mockProj,
                mockProj.AddItemGroup(),
                mockProj.AddPropertyGroup());

            new MigrateTFMRule().Apply(migrationSettings, migrationInputs);
            Console.WriteLine(mockProj.RawXml);

            mockProj.Properties.Count(p => p.Name == "TargetFramework").Should().Be(1);
        }
        public void RuntimeOptions_are_copied_from_projectJson_to_runtimeconfig_template_json_file()
        {
            var testInstance = TestAssetsManager.CreateTestInstance("TestAppWithRuntimeOptions").WithLockFiles();
            var projectDir   = testInstance.Path;
            var projectPath  = Path.Combine(testInstance.Path, "project.json");

            var project           = JObject.Parse(File.ReadAllText(projectPath));
            var rawRuntimeOptions = (JObject)project.GetValue("runtimeOptions");

            var projectContext = ProjectContext.Create(projectDir, FrameworkConstants.CommonFrameworks.NetCoreApp10);

            var testSettings = new MigrationSettings(projectDir, projectDir, "1.0.0", default(ProjectRootElement));
            var testInputs   = new MigrationRuleInputs(new[] { projectContext }, null, null, null);

            new MigrateRuntimeOptionsRule().Apply(testSettings, testInputs);

            var migratedRuntimeOptionsPath = Path.Combine(projectDir, s_runtimeConfigFileName);

            File.Exists(migratedRuntimeOptionsPath).Should().BeTrue();
            Console.WriteLine(migratedRuntimeOptionsPath);

            var migratedRuntimeOptionsContent = JObject.Parse(File.ReadAllText(migratedRuntimeOptionsPath));

            JToken.DeepEquals(rawRuntimeOptions, migratedRuntimeOptionsContent).Should().BeTrue();
        }
        public void RuntimeOptionsAreCopiedFromProjectJsonToRuntimeConfigTemplateJsonFile()
        {
            var testInstance = TestAssets.Get("TestAppWithRuntimeOptions")
                               .CreateInstance()
                               .WithSourceFiles()
                               .Root;

            var projectDir  = testInstance.FullName;
            var projectPath = Path.Combine(projectDir, "project.json");

            var project           = JObject.Parse(File.ReadAllText(projectPath));
            var rawRuntimeOptions = (JObject)project.GetValue("runtimeOptions");

            var projectContext = ProjectContext.Create(projectDir, FrameworkConstants.CommonFrameworks.NetCoreApp10);

            var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(projectDir, projectDir, default(ProjectRootElement));
            var testInputs   = new MigrationRuleInputs(new[] { projectContext }, null, null, null);

            new MigrateRuntimeOptionsRule().Apply(testSettings, testInputs);

            var migratedRuntimeOptionsPath = Path.Combine(projectDir, s_runtimeConfigFileName);

            File.Exists(migratedRuntimeOptionsPath).Should().BeTrue();

            var migratedRuntimeOptionsContent = JObject.Parse(File.ReadAllText(migratedRuntimeOptionsPath));

            JToken.DeepEquals(rawRuntimeOptions, migratedRuntimeOptionsContent).Should().BeTrue();
        }
示例#15
0
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            var csproj        = migrationRuleInputs.OutputMSBuildProject;
            var propertyGroup = migrationRuleInputs.CommonPropertyGroup;

            CleanExistingProperties(csproj);
            CleanExistingPackageReferences(csproj);

            if (migrationRuleInputs.IsMultiTFM)
            {
                _transformApplicator.Execute(
                    FrameworksTransform.Transform(
                        migrationRuleInputs.ProjectContexts.Select(p => p.TargetFramework)),
                    propertyGroup,
                    mergeExisting: true);
            }
            else
            {
                _transformApplicator.Execute(
                    FrameworkTransform.Transform(
                        migrationRuleInputs.ProjectContexts.Single().TargetFramework),
                    propertyGroup,
                    mergeExisting: true);
            }
        }
        public void SpecifiedDefaultPropertiesAreRemovedWhenTheyExistInTheCsprojTemplate()
        {
            // Setup project with default properties
            var defaultPropertiesExpectedToBeRemoved = new string[]
            {
                "OutputType",
                "TargetExt"
            };

            var defaultValue = "defaultValue";

            var templateProj         = ProjectRootElement.Create();
            var defaultPropertyGroup = templateProj.AddPropertyGroup();

            foreach (var defaultPropertyName in defaultPropertiesExpectedToBeRemoved)
            {
                defaultPropertyGroup.AddProperty(defaultPropertyName, defaultValue);
            }

            // Setup projectcontext
            var testProjectDirectory = TestAssetsManager.CreateTestInstance("TestAppWithRuntimeOptions").Path;
            var projectContext       = ProjectContext.Create(testProjectDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);

            var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(testProjectDirectory, testProjectDirectory, templateProj);
            var testInputs   = new MigrationRuleInputs(new[] { projectContext }, templateProj, templateProj.AddItemGroup(),
                                                       templateProj.AddPropertyGroup());

            new MigrateBuildOptionsRule().Apply(testSettings, testInputs);

            defaultPropertyGroup.Properties.Count.Should().Be(0);
        }
示例#17
0
        public void MigratingLibWithMultipleTFMsDoesNotAddRuntimes()
        {
            var testDirectory = Temp.CreateDirectory().Path;
            var testPJ        = new ProjectJsonBuilder(TestAssets)
                                .FromTestAssetBase("PJLibWithMultipleFrameworks")
                                .SaveToDisk(testDirectory);

            var projectContexts = ProjectContext.CreateContextForEachFramework(testDirectory);
            var mockProj        = ProjectRootElement.Create();

            var migrationSettings =
                MigrationSettings.CreateMigrationSettingsTestHook(testDirectory, testDirectory, mockProj);
            var migrationInputs = new MigrationRuleInputs(
                projectContexts,
                mockProj,
                mockProj.AddItemGroup(),
                mockProj.AddPropertyGroup());

            new MigrateTFMRule().Apply(migrationSettings, migrationInputs);

            var reason = "Should not add runtime identifiers for libraries";

            mockProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(0, reason);
            mockProj.Properties.Count(p => p.Name == "RuntimeIdentifier").Should().Be(0, reason);
        }
示例#18
0
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            MigrationTrace.Instance.WriteLine($"Executing rule: {nameof(MigrateConfigurationsRule)}");
            var projectContext = migrationRuleInputs.DefaultProjectContext;
            var configurations = projectContext.ProjectFile.GetConfigurations().ToList();

            var frameworks = new List <NuGetFramework>();

            frameworks.AddRange(projectContext.ProjectFile.GetTargetFrameworks().Select(t => t.FrameworkName));

            if (!configurations.Any() && !frameworks.Any())
            {
                MigrationTrace.Instance.WriteLine($"{nameof(MigrateConfigurationsRule)}: No configuration or framework build options found in project");
                return;
            }

            foreach (var framework in frameworks)
            {
                MigrateConfiguration(projectContext.ProjectFile, framework, migrationSettings, migrationRuleInputs);
            }

            foreach (var configuration in configurations)
            {
                MigrateConfiguration(projectContext.ProjectFile, configuration, migrationSettings, migrationRuleInputs);
            }
        }
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            MigrationTrace.Instance.WriteLine(String.Format(LocalizableStrings.ExecutingRule, nameof(MigrateConfigurationsRule)));
            var projectContext = migrationRuleInputs.DefaultProjectContext;
            var configurations = projectContext.ProjectFile.GetConfigurations().ToList();

            var frameworks = new List <NuGetFramework>();

            frameworks.AddRange(projectContext.ProjectFile.GetTargetFrameworks().Select(t => t.FrameworkName));

            if (!configurations.Any() && !frameworks.Any())
            {
                MigrationTrace.Instance.WriteLine(String.Format(LocalizableStrings.NoConfigurationOrFrameworkFoundInProject, nameof(MigrateConfigurationsRule)));

                return;
            }

            foreach (var framework in frameworks)
            {
                MigrateConfiguration(projectContext.ProjectFile, framework, migrationSettings, migrationRuleInputs);
            }

            foreach (var configuration in configurations)
            {
                MigrateConfiguration(projectContext.ProjectFile, configuration, migrationSettings, migrationRuleInputs);
            }
        }
示例#20
0
        private IEnumerable <string> MigrateXProjProjectDependencies(MigrationRuleInputs migrationRuleInputs)
        {
            var csprojReferenceItems = _projectDependencyFinder.ResolveXProjProjectDependencies(migrationRuleInputs.ProjectXproj);

            if (!csprojReferenceItems.Any())
            {
                return(Enumerable.Empty <string>());
            }

            var csprojTransformedReferences = new List <ProjectItemElement>();

            foreach (var csprojReferenceItem in csprojReferenceItems)
            {
                var conditionChain = csprojReferenceItem.ConditionChain();
                var condition      = string.Join(" and ", conditionChain);

                var referenceInclude = string.Join(";", csprojReferenceItem.Includes()
                                                   .Where(include =>
                                                          string.Equals(Path.GetExtension(include), ".csproj", StringComparison.OrdinalIgnoreCase)));

                var transformItem = ProjectDependencyStringTransform.Transform(referenceInclude);
                transformItem.Condition = condition;

                csprojTransformedReferences.Add(transformItem);
            }

            MigrationTrace.Instance.WriteLine(String.Format(LocalizableStrings.MigratingCountXprojToCsprojReferences, nameof(MigrateProjectDependenciesRule), csprojTransformedReferences.Count()));

            foreach (var csprojTransformedReference in csprojTransformedReferences)
            {
                _transformApplicator.Execute(csprojTransformedReference, migrationRuleInputs.CommonItemGroup, true);
            }

            return(csprojTransformedReferences.SelectMany(r => r.Includes()));
        }
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            var csproj         = migrationRuleInputs.OutputMSBuildProject;
            var projectContext = migrationRuleInputs.DefaultProjectContext;

            var project     = migrationRuleInputs.DefaultProjectContext.ProjectFile;
            var projectType = project.GetProjectType();

            var copyToPublishDirectoryTransform =
                projectType == ProjectType.Web ?
                CopyToPublishDirectoryTransformForWeb :
                CopyToPublishDirectoryTransform;

            ExecuteTransformation(
                copyToPublishDirectoryTransform,
                projectContext.ProjectFile.PublishOptions,
                migrationRuleInputs);

            if (projectContext.ProjectFile.PublishOptions != null)
            {
                ExecuteTransformation(
                    DoNotCopyToPublishDirectoryTransform,
                    new ExcludeContext(
                        projectContext.ProjectFile.PublishOptions.SourceBasePath,
                        projectContext.ProjectFile.PublishOptions.Option,
                        projectContext.ProjectFile.PublishOptions.RawObject,
                        projectContext.ProjectFile.PublishOptions.BuiltInsInclude?.ToArray(),
                        projectContext.ProjectFile.PublishOptions.BuiltInsExclude?.ToArray()),
                    migrationRuleInputs);
            }
        }
示例#22
0
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            var outputName = migrationRuleInputs.DefaultProjectContext.GetProjectName();

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

            migrationRuleInputs.OutputMSBuildProject.Save(outputProject);
        }
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            var outputProject = migrationRuleInputs.OutputMSBuildProject;

            CleanEmptyPropertiesAndItems(outputProject);
            CleanPropertiesThatDontChangeValue(outputProject);
            CleanEmptyPropertyAndItemGroups(outputProject);
        }
示例#24
0
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            var outputName = Path.GetFileNameWithoutExtension(
                migrationRuleInputs.DefaultProjectContext.GetOutputPaths("_").CompilationFiles.Assembly);

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

            migrationRuleInputs.OutputMSBuildProject.Save(outputProject);
        }
示例#25
0
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            var projectContext = migrationRuleInputs.DefaultProjectContext;
            var packOptions    = projectContext.ProjectFile.PackOptions;

            TransformProperties(packOptions, migrationRuleInputs.CommonPropertyGroup);

            TransformPackFiles(packOptions, migrationRuleInputs.CommonItemGroup);
        }
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            var propertyGroup = migrationRuleInputs.CommonPropertyGroup;

            _transformApplicator.Execute(
                RuntimeIdentifiersTransform.Transform(migrationRuleInputs.DefaultProjectContext.ProjectFile.Runtimes),
                propertyGroup,
                mergeExisting: true);
        }
示例#27
0
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            var outputName = migrationRuleInputs.DefaultProjectContext.GetProjectName();

            string csprojName    = $"{GetContainingFolderName(migrationSettings.ProjectDirectory)}.csproj";
            var    outputProject = Path.Combine(migrationSettings.OutputDirectory, csprojName);

            migrationRuleInputs.OutputMSBuildProject.Save(outputProject);
        }
示例#28
0
 public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
 {
     foreach (var element in
              migrationRuleInputs.OutputMSBuildProject.Children
              .Where(c => c.Label == AddDefaultsToProjectRule.c_DefaultsProjectElementContainerLabel))
     {
         element.Parent.RemoveChild(element);
     }
 }
        public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
        {
            var project = migrationRuleInputs.DefaultProjectContext.ProjectFile;
            var type    = project.GetProjectType();

            if (type == ProjectType.Web)
            {
                ReplaceSdkWithWebSdk(migrationSettings);
            }
        }
示例#30
0
        private void MigrateConfiguration(
            Project project,
            NuGetFramework framework,
            MigrationSettings migrationSettings,
            MigrationRuleInputs migrationRuleInputs)
        {
            var buildOptions           = project.GetRawCompilerOptions(framework);
            var configurationCondition = framework.GetMSBuildCondition();

            MigrateConfiguration(buildOptions, configurationCondition, migrationSettings, migrationRuleInputs);
        }