コード例 #1
0
        public void UpdateProjectMissingGroup()
        {
            var properties = new Dictionary <string, string>
            {
                { "Version", "2.0.0.0" },
                { "Copyright", "Copyright 2018 LoreSoft" }
            };

            var xml      = "<Project>\r\n</Project>";
            var document = XDocument.Parse(xml);


            var updater = new ProjectUpdater();

            updater.Properties = properties;
            updater.Logger     = Output.WriteLine;

            updater.UpdateProject(document);

            var result = document.ToString();

            var expected = "<Project>\r\n  <PropertyGroup>\r\n    <Version>2.0.0.0</Version>\r\n    <Copyright>Copyright 2018 LoreSoft</Copyright>\r\n  </PropertyGroup>\r\n</Project>";

            result.Should().Be(expected);
        }
コード例 #2
0
        public void UpdateProjectComplex()
        {
            var properties = new Dictionary <string, string>
            {
                { "Version", "2.0.0.0" },
                { "Description", "Nested Version" }
            };

            var xml      = "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n  <PropertyGroup>\r\n    <TargetFrameworks>net45;netstandard2.0</TargetFrameworks>\r\n  </PropertyGroup>\r\n  <PropertyGroup>\r\n    <Description>Test</Description>\r\n  </PropertyGroup>\r\n  <PropertyGroup>\r\n    <Product>dotnet-property</Product>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\" \'$(TargetFramework)\' == \'netstandard2.0\' \">\r\n    <Description>Test (.NET Core 2.0) </Description>\r\n  </PropertyGroup>\r\n</Project>";
            var document = XDocument.Parse(xml);


            var updater = new ProjectUpdater();

            updater.Properties = properties;
            updater.Logger     = Output.WriteLine;

            updater.UpdateProject(document);

            var result = document.ToString();

            var expected = "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n  <PropertyGroup>\r\n    <TargetFrameworks>net45;netstandard2.0</TargetFrameworks>\r\n  </PropertyGroup>\r\n  <PropertyGroup>\r\n    <Description>Nested Version</Description>\r\n  </PropertyGroup>\r\n  <PropertyGroup>\r\n    <Product>dotnet-property</Product>\r\n    <Version>2.0.0.0</Version>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\" \'$(TargetFramework)\' == \'netstandard2.0\' \">\r\n    <Description>Test (.NET Core 2.0) </Description>\r\n  </PropertyGroup>\r\n</Project>";

            result.Should().Be(expected);
        }
コード例 #3
0
        public void UpdateProjectNestedGroup()
        {
            var properties = new Dictionary <string, string>
            {
                { "Version", "2.0.0.0" },
                { "Description", "Nested Version" }
            };

            var projectPath = @"samples\NestedGroup.xml";


            var updater = new ProjectUpdater();

            updater.Properties = properties;
            updater.Logger     = Output.WriteLine;

            updater.UpdateProject(projectPath);
        }
コード例 #4
0
        public void UpdateProjectSampleLibrary()
        {
            var properties = new Dictionary <string, string>
            {
                { "Version", "2.0.0.0" },
                { "Copyright", "Copyright 2018 LoreSoft" }
            };

            var projectPath = @"samples\SampleLibrary.xml";


            var updater = new ProjectUpdater();

            updater.Properties = properties;
            updater.Logger     = Output.WriteLine;

            updater.UpdateProject(projectPath);
        }