From b324fb2e41613efb5d54fc75bd2fcc6cc9af4373 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 26 Nov 2023 16:46:54 +0100 Subject: [PATCH] Multi-Target .NET 8 (#362) --- .appveyor.yml | 1 + azure-pipelines.yml | 4 ++++ global.json | 2 +- nuspec/nuget/Cake.Issues.MsBuild.nuspec | 6 ++++++ .../Cake.Issues.MsBuild.Tests.csproj | 2 +- .../FakeMsBuildLogFileFormat.cs | 7 +------ .../Cake.Issues.MsBuild.csproj | 2 +- .../XmlFileLoggerLogFileFormat.cs | 18 +++++------------- .../MsBuildIssuesProvider.cs | 14 +++----------- .../MsBuildRuleUrlResolver.cs | 8 ++++---- src/Directory.Build.props | 5 +++++ 11 files changed, 32 insertions(+), 37 deletions(-) create mode 100644 src/Directory.Build.props diff --git a/.appveyor.yml b/.appveyor.yml index 806863a..b189f2f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -13,6 +13,7 @@ install: - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 5.0.408 -InstallDir $env:DOTNET_INSTALL_DIR' - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 6.0.417 -InstallDir $env:DOTNET_INSTALL_DIR' - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 7.0.404 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 8.0.100 -InstallDir $env:DOTNET_INSTALL_DIR' - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" - ps: dotnet --info diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 725f28f..ea5955a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,5 +27,9 @@ jobs: inputs: version: '7.x' displayName: 'Install .NET 7' + - task: UseDotNet@2 + inputs: + version: '8.x' + displayName: 'Install .NET 8' - powershell: ./build.ps1 displayName: 'Cake Build' \ No newline at end of file diff --git a/global.json b/global.json index 110572a..3660ff8 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { "allowPrerelease": true, - "version": "7.0.404", + "version": "8.0.100", "rollForward": "latestFeature" } } \ No newline at end of file diff --git a/nuspec/nuget/Cake.Issues.MsBuild.nuspec b/nuspec/nuget/Cake.Issues.MsBuild.nuspec index ab3dd0d..e35164e 100644 --- a/nuspec/nuget/Cake.Issues.MsBuild.nuspec +++ b/nuspec/nuget/Cake.Issues.MsBuild.nuspec @@ -40,5 +40,11 @@ See the Project Site for an overview of the whole ecosystem of addins for workin + + + + + + \ No newline at end of file diff --git a/src/Cake.Issues.MsBuild.Tests/Cake.Issues.MsBuild.Tests.csproj b/src/Cake.Issues.MsBuild.Tests/Cake.Issues.MsBuild.Tests.csproj index 8284b27..70ace91 100644 --- a/src/Cake.Issues.MsBuild.Tests/Cake.Issues.MsBuild.Tests.csproj +++ b/src/Cake.Issues.MsBuild.Tests/Cake.Issues.MsBuild.Tests.csproj @@ -1,7 +1,7 @@ - net6.0;net7.0 + net6.0;net7.0;net8.0 false Cake.Issues Copyright © BBT Software AG and contributors diff --git a/src/Cake.Issues.MsBuild.Tests/FakeMsBuildLogFileFormat.cs b/src/Cake.Issues.MsBuild.Tests/FakeMsBuildLogFileFormat.cs index 9c4883d..a222f30 100644 --- a/src/Cake.Issues.MsBuild.Tests/FakeMsBuildLogFileFormat.cs +++ b/src/Cake.Issues.MsBuild.Tests/FakeMsBuildLogFileFormat.cs @@ -4,13 +4,8 @@ using System.Collections.Generic; using Cake.Core.Diagnostics; - internal class FakeMsBuildLogFileFormat : BaseMsBuildLogFileFormat + internal class FakeMsBuildLogFileFormat(ICakeLog log) : BaseMsBuildLogFileFormat(log) { - public FakeMsBuildLogFileFormat(ICakeLog log) - : base(log) - { - } - public new (bool Valid, string FilePath) ValidateFilePath(string filePath, IRepositorySettings repositorySettings) { return base.ValidateFilePath(filePath, repositorySettings); diff --git a/src/Cake.Issues.MsBuild/Cake.Issues.MsBuild.csproj b/src/Cake.Issues.MsBuild/Cake.Issues.MsBuild.csproj index 728e0bd..c437eea 100644 --- a/src/Cake.Issues.MsBuild/Cake.Issues.MsBuild.csproj +++ b/src/Cake.Issues.MsBuild/Cake.Issues.MsBuild.csproj @@ -1,7 +1,7 @@ - net6.0;net7.0 + net6.0;net7.0;net8.0 MsBuild support for the Cake.Issues Addin for Cake Build Automation System BBT Software AG BBT Software AG diff --git a/src/Cake.Issues.MsBuild/LogFileFormat/XmlFileLoggerLogFileFormat.cs b/src/Cake.Issues.MsBuild/LogFileFormat/XmlFileLoggerLogFileFormat.cs index e61df4b..45bad41 100644 --- a/src/Cake.Issues.MsBuild/LogFileFormat/XmlFileLoggerLogFileFormat.cs +++ b/src/Cake.Issues.MsBuild/LogFileFormat/XmlFileLoggerLogFileFormat.cs @@ -10,17 +10,9 @@ /// /// MsBuild log format as written by the XmlFileLogger class from MSBuild Extension Pack. /// - internal class XmlFileLoggerLogFileFormat : BaseMsBuildLogFileFormat + /// The Cake log instance. + internal class XmlFileLoggerLogFileFormat(ICakeLog log) : BaseMsBuildLogFileFormat(log) { - /// - /// Initializes a new instance of the class. - /// - /// The Cake log instance. - public XmlFileLoggerLogFileFormat(ICakeLog log) - : base(log) - { - } - /// public override IEnumerable ReadIssues( MsBuildIssuesProvider issueProvider, @@ -54,14 +46,14 @@ public override IEnumerable ReadIssues( } // Read affected project from the warning or error. - if (!this.TryGetProject(element, repositorySettings, out string projectFileRelativePath)) + if (!this.TryGetProject(element, repositorySettings, out var projectFileRelativePath)) { this.Log.Information("Skip element since project could not be parsed"); continue; } // Read affected file from the warning or error. - if (!this.TryGetFile(element, repositorySettings, out string fileName)) + if (!this.TryGetFile(element, repositorySettings, out var fileName)) { this.Log.Information("Skip element since file path could not be parsed"); continue; @@ -82,7 +74,7 @@ public override IEnumerable ReadIssues( } // Read rule code from the warning or error. - if (!this.TryGetRule(element, out string rule)) + if (!this.TryGetRule(element, out var rule)) { this.Log.Information("Skip element since rule could not be parsed"); continue; diff --git a/src/Cake.Issues.MsBuild/MsBuildIssuesProvider.cs b/src/Cake.Issues.MsBuild/MsBuildIssuesProvider.cs index 7001bf2..7dca2fa 100644 --- a/src/Cake.Issues.MsBuild/MsBuildIssuesProvider.cs +++ b/src/Cake.Issues.MsBuild/MsBuildIssuesProvider.cs @@ -5,18 +5,10 @@ /// /// Provider for issues reported as MsBuild warnings. /// - public class MsBuildIssuesProvider : BaseMultiFormatIssueProvider + /// The Cake log context. + /// Settings for reading the log file. + public class MsBuildIssuesProvider(ICakeLog log, MsBuildIssuesSettings settings) : BaseMultiFormatIssueProvider(log, settings) { - /// - /// Initializes a new instance of the class. - /// - /// The Cake log context. - /// Settings for reading the log file. - public MsBuildIssuesProvider(ICakeLog log, MsBuildIssuesSettings settings) - : base(log, settings) - { - } - /// /// Gets the name of the MsBuild issue provider. /// This name can be used to identify issues based on the property. diff --git a/src/Cake.Issues.MsBuild/MsBuildRuleUrlResolver.cs b/src/Cake.Issues.MsBuild/MsBuildRuleUrlResolver.cs index a0022be..29d6b8f 100644 --- a/src/Cake.Issues.MsBuild/MsBuildRuleUrlResolver.cs +++ b/src/Cake.Issues.MsBuild/MsBuildRuleUrlResolver.cs @@ -20,25 +20,25 @@ private MsBuildRuleUrlResolver() // .NET SDK analyzers this.AddUrlResolver(x => - x.Category.ToUpperInvariant() == "CA" ? + x.Category.Equals("CA", StringComparison.OrdinalIgnoreCase) ? new Uri("https://www.google.com/search?q=%22" + x.Rule + ":%22+site:learn.microsoft.com") : null); // StyleCop analyzer rules this.AddUrlResolver(x => - x.Category.ToUpperInvariant() == "SA" ? + x.Category.Equals("SA", StringComparison.OrdinalIgnoreCase) ? new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/" + x.Rule + ".md") : null); // SonarLint rules this.AddUrlResolver(x => - x.Category.ToUpperInvariant() == "S" ? + x.Category.Equals("S", StringComparison.OrdinalIgnoreCase) ? new Uri("https://rules.sonarsource.com/csharp/RSPEC-" + x.RuleId) : null); // Roslynator rules this.AddUrlResolver(x => - x.Category.ToUpperInvariant() == "RCS" ? + x.Category.Equals("RCS", StringComparison.OrdinalIgnoreCase) ? new Uri("https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/" + x.Rule + ".md") : null); } diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..a95ac95 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,5 @@ + + + latest + + \ No newline at end of file