Beispiel #1
0
        public void It_migrates_csproj_ProjectReference_in_xproj(string projectReference, string[] expectedMigratedReferences)
        {
            var xproj = ProjectRootElement.Create();

            xproj.AddItem("ProjectReference", projectReference);

            var projectReferenceName = Path.GetFileNameWithoutExtension(projectReference);

            var projectJson = @"
                {
                    ""dependencies"": {" +
                              $"\"{projectReferenceName}\"" + @": {
                            ""target"" : ""project""
                        }
                    }
                }
            ";

            var testDirectory = Temp.CreateDirectory().Path;
            var migratedProj  = TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
            {
                new MigrateProjectDependenciesRule()
            }, projectJson, testDirectory, xproj);

            var migratedProjectReferenceItems = migratedProj.Items.Where(i => i.ItemType == "ProjectReference");

            migratedProjectReferenceItems.Should().HaveCount(expectedMigratedReferences.Length);
            migratedProjectReferenceItems.Select(m => m.Include).Should().BeEquivalentTo(expectedMigratedReferences);
        }
Beispiel #2
0
        public void It_migrates_csproj_ProjectReference_in_xproj_including_condition_on_ProjectReference_parent()
        {
            var projectReference    = "some/to.csproj";
            var xproj               = ProjectRootElement.Create();
            var csprojReferenceItem = xproj.AddItem("ProjectReference", projectReference);

            csprojReferenceItem.Parent.Condition = " '$(Foo)' == 'bar' ";

            var projectReferenceName = Path.GetFileNameWithoutExtension(projectReference);

            var projectJson = @"
                {
                    ""dependencies"": {" +
                              $"\"{projectReferenceName}\"" + @": {
                            ""target"" : ""project""
                        }
                    }
                }
            ";

            var testDirectory = Temp.CreateDirectory().Path;
            var migratedProj  = TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
            {
                new MigrateProjectDependenciesRule()
            }, projectJson, testDirectory, xproj);

            var migratedProjectReferenceItems = migratedProj.Items.Where(i => i.ItemType == "ProjectReference");

            migratedProjectReferenceItems.Should().HaveCount(1);

            var migratedProjectReferenceItem = migratedProjectReferenceItems.First();

            migratedProjectReferenceItem.Include.Should().Be(projectReference);
            migratedProjectReferenceItem.Condition.Should().Be(" '$(Foo)' == 'bar' ");
        }
 private ProjectRootElement RunPropertiesRuleOnPj(string project, string testDirectory = null)
 {
     testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
     return(TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
     {
         new MigrateRootOptionsRule()
     }, project, testDirectory));
 }
 private ProjectRootElement RunPackageDependenciesRuleOnPj(string s, string testDirectory = null)
 {
     testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
     return(TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
     {
         new MigratePackageDependenciesAndToolsRule()
     }, s, testDirectory));
 }
 private ProjectRootElement RunMigrateRuntimeOptionsRulePj(string s, string testDirectory = null)
 {
     testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
     return(TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
     {
         new MigrateRuntimeOptionsRule()
     }, s, testDirectory));
 }
Beispiel #6
0
 private ProjectRootElement RunPublishAndBuildOptionsRuleOnPj(string s, string testDirectory = null)
 {
     testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
     return(TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
     {
         new MigrateBuildOptionsRule(),
         new MigratePublishOptionsRule()
     }, s, testDirectory));
 }
        protected ProjectRootElement RunPackageDependenciesRuleOnPj(string s, string testDirectory = null)
        {
            testDirectory =
                testDirectory ??
                Temp.CreateDirectory().DirectoryInfo.CreateSubdirectory("project").FullName;

            return(TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
            {
                new MigratePackageDependenciesAndToolsRule()
            }, s, testDirectory));
        }
Beispiel #8
0
        public void It_has_no_runtimes_to_migrate()
        {
            var projectJson = @"
                {
                }
            ";

            var testDirectory = Temp.CreateDirectory().Path;
            var migratedProj  = TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
            {
                new MigrateRuntimesRule()
            }, projectJson, testDirectory);

            migratedProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(0);
        }
Beispiel #9
0
        private string RunMigrateWebSdkRuleOnPj(string s, string testDirectory = null)
        {
            testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
            var csprojFilePath = Path.Combine(testDirectory, $"{GetContainingFolderName(testDirectory)}.csproj");

            File.WriteAllText(csprojFilePath, @"
                <Project Sdk=""Microsoft.NET.Sdk"" ToolsVersion=""15.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
                  <PropertyGroup />
                  <ItemGroup />
                </Project>");

            TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
            {
                new MigrateWebSdkRule()
            }, s, testDirectory);

            return(csprojFilePath);
        }
Beispiel #10
0
        public void It_migrates_runtimes()
        {
            var projectJson = @"
                {
                    ""runtimes"": {
                        ""win7-x64"": { },
                        ""win7-x86"": { },
                        ""osx.10.10-x64"": { }
                    }
                }
            ";

            var testDirectory = Temp.CreateDirectory().Path;
            var migratedProj  = TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
            {
                new MigrateRuntimesRule()
            }, projectJson, testDirectory);

            migratedProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(1);
            migratedProj.Properties.First(p => p.Name == "RuntimeIdentifiers").Value
            .Should().Be("win7-x64;win7-x86;osx.10.10-x64");
        }
 private ProjectRootElement RunRulesOnPj(string s, IMigrationRule[] migrationRules, string testDirectory = null)
 {
     testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
     return(TemporaryProjectFileRuleRunner.RunRules(migrationRules, s, testDirectory));
 }