Пример #1
0
        public void OutputPath_Is_Correct(string platform)
        {
            var projectXml =
                "<Project Sdk=\"Microsoft.NET.Sdk\">" +
                "<PropertyGroup>" +
                "<TargetFramework>netcoreapp2.0</TargetFramework>" +
                "</PropertyGroup>" +
                "<PropertyGroup " +
                "Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \">" +
                $"<OutputPath>bin\\Debug</OutputPath>" +
                "</PropertyGroup>" +
                "<PropertyGroup " +
                "Condition=\" '$(Configuration)|$(Platform)' == 'Debug|x86' \">" +
                $"<OutputPath>bin\\Debug\\x86</OutputPath>" +
                "</PropertyGroup>" +
                "<PropertyGroup " +
                "Condition=\" '$(Configuration)|$(Platform)' == 'Debug|x64' \">" +
                $"<OutputPath>bin\\Debug\\x64</OutputPath>" +
                "</PropertyGroup>" +
                "</Project>";

            var projectContent     = XDocument.Load(new StringReader(projectXml));
            var project            = new XmlMsBuildProject(projectContent);
            var expectedOutputPath = "bin\\Debug";

            if (platform != "AnyCPU")
            {
                expectedOutputPath += $"\\{platform}";
            }
            Assert.Equal(expectedOutputPath, project.GetOutputPath("Debug", platform));
        }
Пример #2
0
        public void Default_AssemblyName_Is_Null()
        {
            var projectXml =
                "<Project Sdk=\"Microsoft.NET.Sdk\">" +
                "<PropertyGroup>" +
                "<TargetFramework>netcoreapp2.0</TargetFramework>" +
                "</PropertyGroup>" +
                "</Project>";

            var projectContent = XDocument.Load(new StringReader(projectXml));
            var project        = new XmlMsBuildProject(projectContent);

            Assert.Null(project.AssemblyName);
        }
Пример #3
0
        public void Default_OutputPath_Is_Null()
        {
            var projectXml =
                "<Project Sdk=\"Microsoft.NET.Sdk\">" +
                "<PropertyGroup>" +
                "<TargetFramework>netcoreapp2.0</TargetFramework>" +
                "</PropertyGroup>" +
                "</Project>";

            var projectContent = XDocument.Load(new StringReader(projectXml));
            var project        = new XmlMsBuildProject(projectContent);

            Assert.Null(project.GetOutputPath("Debug", "AnyCPU"));
        }
Пример #4
0
        public void Default_OutputType_Is_Library()
        {
            var projectXml =
                "<Project Sdk=\"Microsoft.NET.Sdk\">" +
                "<PropertyGroup>" +
                "<TargetFramework>netcoreapp2.0</TargetFramework>" +
                "</PropertyGroup>" +
                "</Project>";

            var projectContent = XDocument.Load(new StringReader(projectXml));
            var project        = new XmlMsBuildProject(projectContent);

            Assert.Equal("Library", project.OutputType);
        }
Пример #5
0
        public void Default_PlatformTarget_Is_Configuration_AnyCPU(string platform)
        {
            var projectXml =
                "<Project Sdk=\"Microsoft.NET.Sdk\">" +
                "<PropertyGroup>" +
                "<TargetFramework>netcoreapp2.0</TargetFramework>" +
                "</PropertyGroup>" +
                "</Project>";

            var projectContent = XDocument.Load(new StringReader(projectXml));
            var project        = new XmlMsBuildProject(projectContent);

            Assert.Equal("AnyCPU", project.GetPlatformTarget("Debug", platform));
        }
Пример #6
0
        public void AssemblyName_Is_Correct()
        {
            var projectXml =
                "<Project Sdk=\"Microsoft.NET.Sdk\">" +
                "<PropertyGroup>" +
                "<TargetFramework>netcoreapp2.0</TargetFramework>" +
                "<AssemblyName>MyAssembly</AssemblyName>" +
                "</PropertyGroup>" +
                "</Project>";

            var projectContent = XDocument.Load(new StringReader(projectXml));
            var project        = new XmlMsBuildProject(projectContent);

            Assert.Equal("MyAssembly", project.AssemblyName);
        }
Пример #7
0
        public void OutputType_Is_Correct(string outputType)
        {
            var projectXml =
                "<Project Sdk=\"Microsoft.NET.Sdk\">" +
                "<PropertyGroup>" +
                "<TargetFramework>netcoreapp2.0</TargetFramework>" +
                $"<OutputType>{outputType}</OutputType>" +
                "</PropertyGroup>" +
                "</Project>";

            var projectContent = XDocument.Load(new StringReader(projectXml));
            var project        = new XmlMsBuildProject(projectContent);

            Assert.Equal(outputType, project.OutputType);
        }
Пример #8
0
        public void TargetFrameworks_Is_Correct_For_TargetFramework()
        {
            var projectXml =
                "<Project Sdk=\"Microsoft.NET.Sdk\">" +
                "<PropertyGroup>" +
                "<TargetFramework>netcoreapp2.0</TargetFramework>" +
                "</PropertyGroup>" +
                "</Project>";

            var projectContent   = XDocument.Load(new StringReader(projectXml));
            var project          = new XmlMsBuildProject(projectContent);
            var targetFrameworks = project.TargetFrameworks.ToList();

            Assert.Equal(1, targetFrameworks.Count);
            Assert.Equal("netcoreapp2.0", targetFrameworks[0]);
        }
Пример #9
0
        public void PlatformTarget_Is_Correct(string platform)
        {
            var projectXml =
                "<Project Sdk=\"Microsoft.NET.Sdk\">" +
                "<PropertyGroup>" +
                "<TargetFramework>netcoreapp2.0</TargetFramework>" +
                "</PropertyGroup>" +
                "<PropertyGroup " +
                $"Condition=\" '$(Configuration)|$(Platform)' == 'Debug|{platform}' \">" +
                $"<PlatformTarget>{platform}</PlatformTarget>" +
                "</PropertyGroup>" +
                "</Project>";

            var projectContent = XDocument.Load(new StringReader(projectXml));
            var project        = new XmlMsBuildProject(projectContent);

            Assert.Equal(platform, project.GetPlatformTarget("Debug", platform));
        }
Пример #10
0
        public void TargetFrameworks_Is_Correct_For_TargetFrameworkVersion()
        {
            var projectXml =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<Project " +
                "ToolsVersion=\"14.0\" " +
                "DefaultTargets=\"Build\" " +
                "xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">" +
                "<PropertyGroup>" +
                "<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>" +
                "</PropertyGroup>" +
                "</Project>";

            var projectContent   = XDocument.Load(new StringReader(projectXml));
            var project          = new XmlMsBuildProject(projectContent);
            var targetFrameworks = project.TargetFrameworks.ToList();

            Assert.Equal(1, targetFrameworks.Count);
            Assert.True(targetFrameworks.Contains("v4.6.1"));
        }