diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..c8a14ac --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: loresoft diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a9b840c..fa8c583 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,8 +1,57 @@ version: 2 updates: -- package-ecosystem: nuget - directory: "/" - schedule: - interval: daily - time: "11:00" - open-pull-requests-limit: 10 + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: daily + time: "01:00" + timezone: "America/Chicago" + open-pull-requests-limit: 10 + + - package-ecosystem: nuget + directory: "/" + schedule: + interval: daily + time: "02:00" + timezone: "America/Chicago" + open-pull-requests-limit: 10 + groups: + Azure: + patterns: + - "Azure.*" + - "Microsoft.Azure.*" + - "Microsoft.Extensions.Azure" + AspNetCoreHealthChecks: + patterns: + - "AspNetCore.HealthChecks.*" + AspNetCore: + patterns: + - "Microsoft.AspNetCore.*" + - "Microsoft.Extensions.Features" + MicrosoftExtensions: + patterns: + - "Microsoft.Extensions.*" + EntityFrameworkCore: + patterns: + - "Microsoft.EntityFrameworkCore.*" + OpenTelemetry: + patterns: + - "OpenTelemetry.*" + Serilog: + patterns: + - "Serilog" + - "Serilog.*" + Hangfire: + patterns: + - "Hangfire" + - "Hangfire.*" + Testcontainers: + patterns: + - "Testcontainers.*" + xUnit: + patterns: + - "xunit" + - "xunit.assert" + - "xunit.core" + - "xunit.extensibility.*" + - "xunit.runner.*" diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 240922a..4f9d83b 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -3,7 +3,9 @@ name: Build env: DOTNET_NOLOGO: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - BUILD_PATH: '${{github.workspace}}/artifacts' + DOTNET_ENVIRONMENT: github + ASPNETCORE_ENVIRONMENT: github + BUILD_PATH: "${{github.workspace}}/artifacts" COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} on: @@ -12,7 +14,7 @@ on: - master - develop tags: - - 'v*' + - "v*" pull_request: branches: - master @@ -23,51 +25,42 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Install .NET Core - uses: actions/setup-dotnet@v3 - with: - dotnet-version: | - 6.0.x - 7.0.x - - - name: Restore Dependencies - run: dotnet restore - - - name: Build Solution - run: dotnet build --no-restore --configuration Release - - - name: Run Test - run: dotnet test --configuration Release --collect:"XPlat Code Coverage" --settings coverlet.runsettings - - - name: Generate Coverage - uses: danielpalme/ReportGenerator-GitHub-Action@5.1.23 - with: - reports: '${{github.workspace}}/test/*/TestResults/*/coverage.info' - targetdir: ${{env.BUILD_PATH}} - reporttypes: lcov - - - name: Report Coverage - if: success() - uses: coverallsapp/github-action@v2 - with: - file: artifacts/lcov.info + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.x + + - name: Restore Dependencies + run: dotnet restore + + - name: Build Solution + run: dotnet build --no-restore --configuration Release + + - name: Run Test + run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --settings coverlet.runsettings + + - name: Report Coverage + if: success() + uses: coverallsapp/github-action@v2 + with: + file: "${{github.workspace}}/test/*/TestResults/*/coverage.info" format: lcov - - name: Create Packages - if: success() && github.event_name != 'pull_request' - run: dotnet pack --configuration Release --include-symbols --include-source --no-build --no-restore --output "${{env.BUILD_PATH}}" + - name: Create Packages + if: success() && github.event_name != 'pull_request' + run: dotnet pack --configuration Release --no-build --output "${{env.BUILD_PATH}}" - - name: Upload Packages - if: success() && github.event_name != 'pull_request' - uses: actions/upload-artifact@v3 - with: - name: packages - path: '${{env.BUILD_PATH}}' + - name: Upload Packages + if: success() && github.event_name != 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: packages + path: "${{env.BUILD_PATH}}" deploy: runs-on: ubuntu-latest @@ -75,30 +68,29 @@ jobs: if: success() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) steps: - - name: Download Artifact - uses: actions/download-artifact@v3 - with: - name: packages - - - name: Publish Packages GitHub - run: | - for package in $(find -name "*.nupkg"); do - echo "${0##*/}": Pushing $package... - dotnet nuget push $package --source https://nuget.pkg.github.com/loresoft/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate - done - - - name: Publish Packages feedz - run: | - for package in $(find -name "*.nupkg"); do - echo "${0##*/}": Pushing $package... - dotnet nuget push $package --source https://f.feedz.io/loresoft/open/nuget/index.json --api-key ${{ secrets.FEEDDZ_KEY }} --skip-duplicate - done - - - name: Publish Packages Nuget - if: startsWith(github.ref, 'refs/tags/v') - run: | - for package in $(find -name "*.nupkg"); do - echo "${0##*/}": Pushing $package... - dotnet nuget push $package --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} --skip-duplicate - done - + - name: Download Artifact + uses: actions/download-artifact@v4 + with: + name: packages + + - name: Publish Packages GitHub + run: | + for package in $(find -name "*.nupkg"); do + echo "${0##*/}": Pushing $package... + dotnet nuget push $package --source https://nuget.pkg.github.com/loresoft/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate + done + + - name: Publish Packages feedz + run: | + for package in $(find -name "*.nupkg"); do + echo "${0##*/}": Pushing $package... + dotnet nuget push $package --source https://f.feedz.io/loresoft/open/nuget/index.json --api-key ${{ secrets.FEEDDZ_KEY }} --skip-duplicate + done + + - name: Publish Packages Nuget + if: startsWith(github.ref, 'refs/tags/v') + run: | + for package in $(find -name "*.nupkg"); do + echo "${0##*/}": Pushing $package... + dotnet nuget push $package --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} --skip-duplicate + done diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml new file mode 100644 index 0000000..c52640d --- /dev/null +++ b/.github/workflows/merge.yml @@ -0,0 +1,24 @@ +name: Dependabot Auto-Merge +on: pull_request + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + + steps: + - name: Dependabot Metadata + id: metadata + uses: dependabot/fetch-metadata@v2 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Dependabot Auto-Merge PRs + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/README.md b/README.md index 4d3aaa6..602cc1d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ .NET Core command-line (CLI) tool to update project properties and version numbers on build. +[![Build Project](https://github.com/loresoft/DotNet.Property/actions/workflows/dotnet.yml/badge.svg)](https://github.com/loresoft/DotNet.Property/actions/workflows/dotnet.yml) + +[![Coverage Status](https://coveralls.io/repos/github/loresoft/DotNet.Property/badge.svg)](https://coveralls.io/github/loresoft/DotNet.Property) + +[![NuGet Version](https://img.shields.io/nuget/v/dotnet-property.svg?style=flat-square)](https://www.nuget.org/packages/dotnet-property/) + ## Usage Install the global tool diff --git a/coverlet.runsettings b/coverlet.runsettings index 4eac22c..b28750f 100644 --- a/coverlet.runsettings +++ b/coverlet.runsettings @@ -5,8 +5,6 @@ lcov - Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute,TestSDKAutoGeneratedCode - true diff --git a/src/Directory.Build.props b/src/Directory.Build.props index d4806ce..36520ce 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -18,14 +18,18 @@ true - - portable - true - true - snupkg + + embedded + true + false - + + true + + + + en-US latest enable 1591 @@ -34,10 +38,9 @@ v - + - - + diff --git a/src/DotNet.Property/DotNet.Property.csproj b/src/DotNet.Property/DotNet.Property.csproj index f156c78..9c5736c 100644 --- a/src/DotNet.Property/DotNet.Property.csproj +++ b/src/DotNet.Property/DotNet.Property.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 dotnet-property DotNet.Property dotnet-property @@ -11,7 +11,7 @@ - + diff --git a/src/DotNet.Property/Extensions.cs b/src/DotNet.Property/Extensions.cs index 54a2d3b..6f3b22c 100644 --- a/src/DotNet.Property/Extensions.cs +++ b/src/DotNet.Property/Extensions.cs @@ -1,35 +1,31 @@ -using System; using System.Xml.Linq; -namespace DotNet.Property +namespace DotNet.Property; + +/// +/// Extension methods +/// +public static class Extensions { /// - /// Extension methods + /// Gets the or create an . /// - public static class Extensions + /// The container. + /// The name of the element. + /// + /// or is + public static XElement GetOrCreateElement(this XContainer container, string name) { - /// - /// Gets the or create an . - /// - /// The container. - /// The name of the element. - /// - /// or is - public static XElement GetOrCreateElement(this XContainer container, string name) - { - if (container == null) - throw new ArgumentNullException(nameof(container)); - if (name == null) - throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(container); + ArgumentNullException.ThrowIfNull(name); - var element = container.Element(name); - if (element != null) - return element; + var element = container.Element(name); + if (element != null) + return element; - element = new XElement(name); - container.Add(element); + element = new XElement(name); + container.Add(element); - return element; - } + return element; } -} \ No newline at end of file +} diff --git a/src/DotNet.Property/Program.cs b/src/DotNet.Property/Program.cs index ed97305..e90dde1 100644 --- a/src/DotNet.Property/Program.cs +++ b/src/DotNet.Property/Program.cs @@ -1,45 +1,42 @@ -using System; +namespace DotNet.Property; -namespace DotNet.Property +public static class Program { - public class Program + static int Main(string[] args) { - static int Main(string[] args) + if (args.Length < 2) { - if (args.Length < 2) - { - OutputVersion(); - OutputUsage(); + OutputVersion(); + OutputUsage(); - return 1; - } - - try - { - var updater = new ProjectUpdater(); - updater.Update(args, Environment.CurrentDirectory); - } - catch (Exception ex) - { - Console.Error.WriteLine(ex.ToString()); - return 1; - } - - return 0; + return 1; } - private static void OutputVersion() + try { - Console.WriteLine(".NET Core command-line (CLI) tool to update project properties"); + var updater = new ProjectUpdater(); + updater.Update(args, Environment.CurrentDirectory); } - - private static void OutputUsage() + catch (Exception ex) { - Console.WriteLine(); - Console.WriteLine("Usage: dotnet property :"); - Console.WriteLine(); - Console.WriteLine("Example:"); - Console.WriteLine(" dotnet property \"**/version.props\" Version:\"1.0.0.3\" Copyright:\"Copyright 2018 LoreSoft\""); + Console.Error.WriteLine(ex.ToString()); + return 1; } + + return 0; + } + + private static void OutputVersion() + { + Console.WriteLine(".NET Core command-line (CLI) tool to update project properties"); + } + + private static void OutputUsage() + { + Console.WriteLine(); + Console.WriteLine("Usage: dotnet property :"); + Console.WriteLine(); + Console.WriteLine("Example:"); + Console.WriteLine(" dotnet property \"**/version.props\" Version:\"1.0.0.3\" Copyright:\"Copyright 2018 LoreSoft\""); } } diff --git a/src/DotNet.Property/ProjectUpdater.cs b/src/DotNet.Property/ProjectUpdater.cs index a7d83be..bbc3e12 100644 --- a/src/DotNet.Property/ProjectUpdater.cs +++ b/src/DotNet.Property/ProjectUpdater.cs @@ -1,229 +1,220 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; using System.Xml; using System.Xml.Linq; + using Microsoft.Extensions.FileSystemGlobbing; using Microsoft.Extensions.FileSystemGlobbing.Abstractions; -namespace DotNet.Property +namespace DotNet.Property; + +/// +/// Update .net core project properties +/// +public class ProjectUpdater { + + /// + /// Gets or sets the log writer delegate. + /// + /// + /// The log writer delegate. + /// + public Action Logger { get; set; } = Console.WriteLine; + + /// + /// Gets or sets the properties to update. + /// + /// + /// The properties to update. + /// + public Dictionary Properties { get; set; } = []; + + /// + /// Gets or sets the projects to update as a file glob expression. + /// + /// + /// The projects to update as a file glob expression. + /// + public string Projects { get; set; } = "**/*.props"; + + /// - /// Update .net core project properties + /// Updates .net core projects using the specified command line arguments. The first argument is the project list glob expression. /// - public class ProjectUpdater + /// The arguments used to update project with. + /// The root directory to search for projects. + public void Update(string[] args, string rootDirectory = null) { + Projects = args[0]; + Properties = ParseArguments(args, 1); - /// - /// Gets or sets the log writer delegate. - /// - /// - /// The log writer delegate. - /// - public Action Logger { get; set; } = Console.WriteLine; - - /// - /// Gets or sets the properties to update. - /// - /// - /// The properties to update. - /// - public Dictionary Properties { get; set; } = new Dictionary(); - - /// - /// Gets or sets the projects to update as a file glob expression. - /// - /// - /// The projects to update as a file glob expression. - /// - public string Projects { get; set; } = "**/*.props"; - - - /// - /// Updates .net core projects using the specified command line arguments. The first argument is the project list glob expression. - /// - /// The arguments used to update project with. - /// The root directory to search for projects. - public void Update(string[] args, string rootDirectory = null) - { - Projects = args[0]; - Properties = ParseArguments(args, 1); + WriteLog($"Matching projects: {Projects}"); + var matcher = new Matcher(StringComparison.OrdinalIgnoreCase); + matcher.AddInclude(Projects); - WriteLog($"Matching projects: {Projects}"); - var matcher = new Matcher(StringComparison.OrdinalIgnoreCase); - matcher.AddInclude(Projects); + if (string.IsNullOrEmpty(rootDirectory)) + rootDirectory = Environment.CurrentDirectory; - if (string.IsNullOrEmpty(rootDirectory)) - rootDirectory = Environment.CurrentDirectory; + var currentDirectory = new DirectoryInfo(rootDirectory); + var startingDirectory = new DirectoryInfoWrapper(currentDirectory); + var matchingResult = matcher.Execute(startingDirectory); - var currentDirectory = new DirectoryInfo(rootDirectory); - var startingDirectory = new DirectoryInfoWrapper(currentDirectory); - var matchingResult = matcher.Execute(startingDirectory); + if (!matchingResult.HasMatches) + { + WriteLog($"Error: No Projects found: {Projects}"); + return; + } - if (!matchingResult.HasMatches) + foreach (var fileMatch in matchingResult.Files) + { + var filePath = Path.GetFullPath(fileMatch.Path); + try { - WriteLog($"Error: No Projects found: {Projects}"); - return; + UpdateProject(filePath); } - - foreach (var fileMatch in matchingResult.Files) + catch (Exception ex) { - var filePath = Path.GetFullPath(fileMatch.Path); - try - { - UpdateProject(filePath); - } - catch (Exception ex) - { - Console.Error.WriteLine($"Error occured processing {filePath} : {ex.Message}"); - } + Console.Error.WriteLine($"Error occurred processing {filePath} : {ex.Message}"); } } + } - /// - /// Updates the project at the specified . - /// - /// The file path of the project to update. - /// is - /// is not found. - public void UpdateProject(string filePath) - { - if (filePath == null) - throw new ArgumentNullException(nameof(filePath)); - - if (!File.Exists(filePath)) - throw new ArgumentException($"File not found: {filePath}", nameof(filePath)); - - WriteLog($"Updating Project: {filePath}"); - - XDocument document; - using (var readStream = File.OpenRead(filePath)) - { - document = XDocument.Load(readStream); - } + /// + /// Updates the project at the specified . + /// + /// The file path of the project to update. + /// is + /// is not found. + public void UpdateProject(string filePath) + { + ArgumentNullException.ThrowIfNull(filePath); - UpdateProject(document); + if (!File.Exists(filePath)) + throw new ArgumentException($"File not found: {filePath}", nameof(filePath)); - // save document - var settings = new XmlWriterSettings - { - OmitXmlDeclaration = true, - Indent = true - }; + WriteLog($"Updating Project: {filePath}"); - using (var stream = new FileStream(filePath, FileMode.Create, FileAccess.Write)) - using (var writer = XmlWriter.Create(stream, settings)) - { - document.Save(writer); - } + XDocument document; + using (var readStream = File.OpenRead(filePath)) + { + document = XDocument.Load(readStream); } - /// - /// Updates the project as an . - /// - /// The project document. - /// is - /// Missing root Project node. - public void UpdateProject(XDocument document) - { - if (document == null) - throw new ArgumentNullException(nameof(document)); + UpdateProject(document); - if (Properties == null || Properties.Count == 0) - return; + // save document + var settings = new XmlWriterSettings + { + OmitXmlDeclaration = true, + Indent = true + }; - var projectElement = document.Element("Project"); - if (projectElement == null) - throw new InvalidOperationException("Could not find root Project node. Make sure file has a root Project node without a namespace."); + using var stream = new FileStream(filePath, FileMode.Create, FileAccess.Write); + using var writer = XmlWriter.Create(stream, settings); + document.Save(writer); + } - foreach (var p in Properties) - { - WriteLog($" Set Property '{p.Key}':'{p.Value}'"); + /// + /// Updates the project as an . + /// + /// The project document. + /// is + /// Missing root Project node. + public void UpdateProject(XDocument document) + { + ArgumentNullException.ThrowIfNull(document); - // find last group with element and no condition - var projectGroup = projectElement - .Elements("PropertyGroup") - .LastOrDefault(e => - e.Elements(p.Key).Any() && - (e.HasAttributes == false || e.Attributes().All(a => a.Name != "Condition")) - ); - - // use last group without condition - if (projectGroup == null) - projectGroup = projectElement - .Elements("PropertyGroup") - .LastOrDefault(e => e.HasAttributes == false || e.Attributes().All(a => a.Name != "Condition")); - - // create new if not found - if (projectGroup == null) - projectGroup = projectElement - .GetOrCreateElement("PropertyGroup"); - - projectGroup - .GetOrCreateElement(p.Key) - .SetValue(p.Value); - } - } + if (Properties == null || Properties.Count == 0) + return; + var projectElement = document.Element("Project"); + if (projectElement == null) + throw new InvalidOperationException("Could not find root Project node. Make sure file has a root Project node without a namespace."); - /// - /// Parses the arguments into a dictionary. - /// - /// The arguments. - /// The start index. - /// - /// is - public static Dictionary ParseArguments(string[] args, int startIndex = 0) + foreach (var p in Properties) { - if (args == null) - throw new ArgumentNullException(nameof(args)); + WriteLog($" Set Property '{p.Key}':'{p.Value}'"); + + // find last group with element and no condition + var projectGroup = projectElement + .Elements("PropertyGroup") + .LastOrDefault(e => + e.Elements(p.Key).Any() && + (e.HasAttributes == false || e.Attributes().All(a => a.Name != "Condition")) + ); + + // use last group without condition + if (projectGroup == null) + projectGroup = projectElement + .Elements("PropertyGroup") + .LastOrDefault(e => e.HasAttributes == false || e.Attributes().All(a => a.Name != "Condition")); - var arguments = new Dictionary(StringComparer.OrdinalIgnoreCase); + // create new if not found + if (projectGroup == null) + projectGroup = projectElement + .GetOrCreateElement("PropertyGroup"); - // skip first - for (int i = startIndex; i < args.Length; i++) - { - int keyStartIndex = 0; + projectGroup + .GetOrCreateElement(p.Key) + .SetValue(p.Value); + } + } - if (args[i].StartsWith("--")) - { - keyStartIndex = 2; - } - else if (args[i].StartsWith("-")) - { - keyStartIndex = 1; - } - else if (args[i].StartsWith("/")) - { - keyStartIndex = 1; - } - int separator = args[i].IndexOfAny(new char[] { ':', '=' }); + /// + /// Parses the arguments into a dictionary. + /// + /// The arguments. + /// The start index. + /// + /// is + public static Dictionary ParseArguments(string[] args, int startIndex = 0) + { + if (args == null) + throw new ArgumentNullException(nameof(args)); + + var arguments = new Dictionary(StringComparer.OrdinalIgnoreCase); - if (separator < 0) - { - continue; // an invalid format + // skip first + for (int i = startIndex; i < args.Length; i++) + { + int keyStartIndex = 0; - } + if (args[i].StartsWith("--")) + { + keyStartIndex = 2; + } + else if (args[i].StartsWith('-')) + { + keyStartIndex = 1; + } + else if (args[i].StartsWith('/')) + { + keyStartIndex = 1; + } - var key = args[i].Substring(keyStartIndex, separator - keyStartIndex); - var value = args[i].Substring(separator + 1); + int separator = args[i].IndexOfAny([':', '=']); - arguments[key] = value; + if (separator < 0) + { + continue; // an invalid format } - return arguments; + var key = args[i][keyStartIndex..separator]; + var value = args[i][(separator + 1)..]; + + arguments[key] = value; } + return arguments; + } + - private void WriteLog(string s) - { - if (Logger == null || string.IsNullOrEmpty(s)) - return; + private void WriteLog(string s) + { + if (Logger == null || string.IsNullOrEmpty(s)) + return; - Logger.Invoke(s); - } + Logger.Invoke(s); } } diff --git a/test/DotNet.Property.Tests/DotNet.Property.Tests.csproj b/test/DotNet.Property.Tests/DotNet.Property.Tests.csproj index 8935c13..db94b08 100644 --- a/test/DotNet.Property.Tests/DotNet.Property.Tests.csproj +++ b/test/DotNet.Property.Tests/DotNet.Property.Tests.csproj @@ -1,22 +1,22 @@ - net6.0 + net8.0 false - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/test/DotNet.Property.Tests/ProjectUpdaterTest.cs b/test/DotNet.Property.Tests/ProjectUpdaterTest.cs index 9112432..b4c828f 100644 --- a/test/DotNet.Property.Tests/ProjectUpdaterTest.cs +++ b/test/DotNet.Property.Tests/ProjectUpdaterTest.cs @@ -6,175 +6,174 @@ using Xunit; using Xunit.Abstractions; -namespace DotNet.Property.Tests +namespace DotNet.Property.Tests; + +public class ProjectUpdaterTest { - public class ProjectUpdaterTest + public ProjectUpdaterTest(ITestOutputHelper output) { - public ProjectUpdaterTest(ITestOutputHelper output) - { - Output = output; - } + Output = output; + } - public ITestOutputHelper Output { get; } + public ITestOutputHelper Output { get; } - [Fact] - public void ParseArguments() + [Fact] + public void ParseArguments() + { + var args = ProjectUpdater.ParseArguments(new[] { - var args = ProjectUpdater.ParseArguments(new[] - { - "Version:1.0.0.3", - "Copyright:Copyright 2018 LoreSoft" - }, 0); - - args.Should().NotBeNull(); - args.Count.Should().Be(2); - args["Version"].Should().Be("1.0.0.3"); - args["Copyright"].Should().Be("Copyright 2018 LoreSoft"); - } - - [Fact] - public void ParseArgumentsEquals() + "Version:1.0.0.3", + "Copyright:Copyright 2018 LoreSoft" + }, 0); + + args.Should().NotBeNull(); + args.Count.Should().Be(2); + args["Version"].Should().Be("1.0.0.3"); + args["Copyright"].Should().Be("Copyright 2018 LoreSoft"); + } + + [Fact] + public void ParseArgumentsEquals() + { + var args = ProjectUpdater.ParseArguments(new[] { - var args = ProjectUpdater.ParseArguments(new[] - { - "Version=1.0.0.3", - "Copyright=Copyright 2018 LoreSoft" - }, 0); - - args.Should().NotBeNull(); - args.Count.Should().Be(2); - args["Version"].Should().Be("1.0.0.3"); - args["Copyright"].Should().Be("Copyright 2018 LoreSoft"); - } - - [Fact] - public void ParseArgumentsUrl() + "Version=1.0.0.3", + "Copyright=Copyright 2018 LoreSoft" + }, 0); + + args.Should().NotBeNull(); + args.Count.Should().Be(2); + args["Version"].Should().Be("1.0.0.3"); + args["Copyright"].Should().Be("Copyright 2018 LoreSoft"); + } + + [Fact] + public void ParseArgumentsUrl() + { + var args = ProjectUpdater.ParseArguments(new[] { - var args = ProjectUpdater.ParseArguments(new[] - { - "Version=1.0.0.3", - "PackageProjectUrl=https://test.com", - "SourceProjectUrl=https://other.com" - }, 0); - - args.Should().NotBeNull(); - args.Count.Should().Be(3); - args["Version"].Should().Be("1.0.0.3"); - args["PackageProjectUrl"].Should().Be("https://test.com"); - args["SourceProjectUrl"].Should().Be("https://other.com"); - } - - [Fact] - public void UpdateProject() + "Version=1.0.0.3", + "PackageProjectUrl=https://test.com", + "SourceProjectUrl=https://other.com" + }, 0); + + args.Should().NotBeNull(); + args.Count.Should().Be(3); + args["Version"].Should().Be("1.0.0.3"); + args["PackageProjectUrl"].Should().Be("https://test.com"); + args["SourceProjectUrl"].Should().Be("https://other.com"); + } + + [Fact] + public void UpdateProject() + { + var properties = new Dictionary { - var properties = new Dictionary - { - { "Version", "2.0.0.0" }, - { "Copyright", "Copyright 2018 LoreSoft" } - }; + { "Version", "2.0.0.0" }, + { "Copyright", "Copyright 2018 LoreSoft" } + }; - var xml = "1.0.0.0"; - var document = XDocument.Parse(xml); + var xml = "1.0.0.0"; + var document = XDocument.Parse(xml); - var updater = new ProjectUpdater(); - updater.Properties = properties; - updater.Logger = Output.WriteLine; + var updater = new ProjectUpdater(); + updater.Properties = properties; + updater.Logger = Output.WriteLine; - updater.UpdateProject(document); + updater.UpdateProject(document); - var result = document.ToString(SaveOptions.DisableFormatting); + var result = document.ToString(SaveOptions.DisableFormatting); - var expected = "2.0.0.0Copyright 2018 LoreSoft"; - result.Should().Be(expected); - } + var expected = "2.0.0.0Copyright 2018 LoreSoft"; + result.Should().Be(expected); + } - [Fact] - public void UpdateProjectMissingGroup() + [Fact] + public void UpdateProjectMissingGroup() + { + var properties = new Dictionary { - var properties = new Dictionary - { - { "Version", "2.0.0.0" }, - { "Copyright", "Copyright 2018 LoreSoft" } - }; + { "Version", "2.0.0.0" }, + { "Copyright", "Copyright 2018 LoreSoft" } + }; - var xml = ""; - var document = XDocument.Parse(xml); + var xml = ""; + var document = XDocument.Parse(xml); - var updater = new ProjectUpdater(); - updater.Properties = properties; - updater.Logger = Output.WriteLine; + var updater = new ProjectUpdater(); + updater.Properties = properties; + updater.Logger = Output.WriteLine; - updater.UpdateProject(document); + updater.UpdateProject(document); - var result = document.ToString(SaveOptions.DisableFormatting); + var result = document.ToString(SaveOptions.DisableFormatting); - var expected = "2.0.0.0Copyright 2018 LoreSoft"; - result.Should().Be(expected); - } + var expected = "2.0.0.0Copyright 2018 LoreSoft"; + result.Should().Be(expected); + } - [Fact] - public void UpdateProjectComplex() + [Fact] + public void UpdateProjectComplex() + { + var properties = new Dictionary { - var properties = new Dictionary - { - { "Version", "2.0.0.0" }, - { "Description", "Nested Version" } - }; + { "Version", "2.0.0.0" }, + { "Description", "Nested Version" } + }; - var xml = "net45;netstandard2.0Testdotnet-propertyTest (.NET Core 2.0) "; - var document = XDocument.Parse(xml); + var xml = "net45;netstandard2.0Testdotnet-propertyTest (.NET Core 2.0) "; + var document = XDocument.Parse(xml); - var updater = new ProjectUpdater(); - updater.Properties = properties; - updater.Logger = Output.WriteLine; + var updater = new ProjectUpdater(); + updater.Properties = properties; + updater.Logger = Output.WriteLine; - updater.UpdateProject(document); + updater.UpdateProject(document); - var result = document.ToString(SaveOptions.DisableFormatting); + var result = document.ToString(SaveOptions.DisableFormatting); - var expected = "net45;netstandard2.0Nested Versiondotnet-property2.0.0.0Test (.NET Core 2.0) "; - result.Should().Be(expected); - } + var expected = "net45;netstandard2.0Nested Versiondotnet-property2.0.0.0Test (.NET Core 2.0) "; + result.Should().Be(expected); + } - [Fact] - public void UpdateProjectSampleLibrary() + [Fact] + public void UpdateProjectSampleLibrary() + { + var properties = new Dictionary { - var properties = new Dictionary - { - { "Version", "2.0.0.0" }, - { "Copyright", "Copyright 2018 LoreSoft" } - }; + { "Version", "2.0.0.0" }, + { "Copyright", "Copyright 2018 LoreSoft" } + }; - var projectPath = Path.Combine(Environment.CurrentDirectory, "samples", "SampleLibrary.xml"); + var projectPath = Path.Combine(Environment.CurrentDirectory, "samples", "SampleLibrary.xml"); - var updater = new ProjectUpdater(); - updater.Properties = properties; - updater.Logger = Output.WriteLine; + var updater = new ProjectUpdater(); + updater.Properties = properties; + updater.Logger = Output.WriteLine; - updater.UpdateProject(projectPath); - } + updater.UpdateProject(projectPath); + } - [Fact] - public void UpdateProjectNestedGroup() + [Fact] + public void UpdateProjectNestedGroup() + { + var properties = new Dictionary { - var properties = new Dictionary - { - { "Version", "2.0.0.0" }, - { "Description", "Nested Version" } - }; + { "Version", "2.0.0.0" }, + { "Description", "Nested Version" } + }; - var projectPath = Path.Combine(Environment.CurrentDirectory, "samples", "NestedGroup.xml"); + var projectPath = Path.Combine(Environment.CurrentDirectory, "samples", "NestedGroup.xml"); - var updater = new ProjectUpdater(); - updater.Properties = properties; - updater.Logger = Output.WriteLine; + var updater = new ProjectUpdater(); + updater.Properties = properties; + updater.Logger = Output.WriteLine; - updater.UpdateProject(projectPath); - } + updater.UpdateProject(projectPath); } }