From 52668b10a41cdff5165d8efc8707f686b50812b8 Mon Sep 17 00:00:00 2001 From: Nils Andresen Date: Sun, 24 Nov 2024 00:04:14 +0100 Subject: [PATCH] (#388) Update Cake reference to Cake 5 and CakeContrib.Guidelines to 1.6.1 --- demo/cake/.config/dotnet-tools.json | 4 ++-- demo/cake/build.cake | 4 ++-- demo/frosting/build/Build.csproj | 12 ++++++------ demo/frosting/build/Program.cs | 18 +++++++++++++++++- demo/frosting/build/Tasks/ZipItTask.cs | 2 +- src/Cake.7zip.Tests/Cake.7zip.Tests.csproj | 4 ++-- src/Cake.7zip.Tests/SevenZipRunnerTests.cs | 6 +++--- src/Cake.7zip/Cake.7zip.csproj | 6 +++--- 8 files changed, 36 insertions(+), 20 deletions(-) diff --git a/demo/cake/.config/dotnet-tools.json b/demo/cake/.config/dotnet-tools.json index da200cda..278f2d71 100644 --- a/demo/cake/.config/dotnet-tools.json +++ b/demo/cake/.config/dotnet-tools.json @@ -3,10 +3,10 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "4.0.0", + "version": "5.0.0", "commands": [ "dotnet-cake" ] } } -} \ No newline at end of file +} diff --git a/demo/cake/build.cake b/demo/cake/build.cake index 051506cf..f6d78fc9 100644 --- a/demo/cake/build.cake +++ b/demo/cake/build.cake @@ -1,5 +1,5 @@ #tool "nuget:?package=7-Zip.CommandLine&version=18.1.0" -#r "..\..\src\Cake.7zip\bin\Release\net6.0\Cake.7zip.dll" +#r "..\..\src\Cake.7zip\bin\Release\net8.0\Cake.7zip.dll" /////////////////////////////////////////////////////////////////////////////// // ARGUMENTS @@ -195,4 +195,4 @@ Task("Default") .IsDependentOn("RenameFile") .IsDependentOn("GH78"); -RunTarget(target); \ No newline at end of file +RunTarget(target); diff --git a/demo/frosting/build/Build.csproj b/demo/frosting/build/Build.csproj index 01f3df49..3fa7db6b 100644 --- a/demo/frosting/build/Build.csproj +++ b/demo/frosting/build/Build.csproj @@ -1,18 +1,18 @@ Exe - net6.0 - $(MSBuildProjectDirectory).. + net8.0 + $(MSBuildProjectDirectory)\ - - ..\..\..\src\Cake.7zip\bin\Release\net6.0\Cake.7zip.dll + + $(MSBuildProjectDirectory)\..\..\..\src\Cake.7zip\bin\Release\net8.0\Cake.7zip.dll - + - \ No newline at end of file + diff --git a/demo/frosting/build/Program.cs b/demo/frosting/build/Program.cs index 38cf3532..313a5782 100644 --- a/demo/frosting/build/Program.cs +++ b/demo/frosting/build/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.InteropServices; using Cake.Frosting; namespace Build @@ -8,10 +9,25 @@ public static class Program public static int Main(string[] args) { return new CakeHost() - .InstallTool(new Uri("nuget:?package=7-Zip.CommandLine&version=18.1.0")) + .InstallSevenZip() .UseContext() .UseSetup() .Run(args); } + + private static CakeHost InstallSevenZip(this CakeHost host) + { + // 7-Zip.CommandLine is a windows-only package + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + host.InstallTool(new Uri("nuget:?package=7-Zip.CommandLine&version=18.1.0")); + } + else + { + Console.WriteLine("7-Zip.CommandLine tool not installed. Make sure you hava a version of 7zip installed!"); + } + + return host; + } } } diff --git a/demo/frosting/build/Tasks/ZipItTask.cs b/demo/frosting/build/Tasks/ZipItTask.cs index 511f8c38..eac75574 100644 --- a/demo/frosting/build/Tasks/ZipItTask.cs +++ b/demo/frosting/build/Tasks/ZipItTask.cs @@ -12,7 +12,7 @@ public override void Run(BuildContext context) context.SevenZip(m => m .InAddMode() .WithArchive(context.Output.CombineWithFilePath("archive.zip")) - .WithFiles(context.Root.CombineWithFilePath("README.MD")) + .WithFiles(context.Root.CombineWithFilePath("README.md")) .WithFiles(context.Root.CombineWithFilePath("CODE_OF_CONDUCT.md"))); } } diff --git a/src/Cake.7zip.Tests/Cake.7zip.Tests.csproj b/src/Cake.7zip.Tests/Cake.7zip.Tests.csproj index 2d377558..acdf40a7 100644 --- a/src/Cake.7zip.Tests/Cake.7zip.Tests.csproj +++ b/src/Cake.7zip.Tests/Cake.7zip.Tests.csproj @@ -6,7 +6,7 @@ This is done to make Cake.Recipe avoid using OpenCover. Remove this hack if Cake.Recipe bumps the usage of Cake.Incubator to version 7.0.0 --> netcoreapp3.1 - net6.0;net7.0;net8.0 + net8.0;net9.0 ..\cake.7zip.ruleset false @@ -15,7 +15,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Cake.7zip.Tests/SevenZipRunnerTests.cs b/src/Cake.7zip.Tests/SevenZipRunnerTests.cs index ebebc733..8ed2ce36 100644 --- a/src/Cake.7zip.Tests/SevenZipRunnerTests.cs +++ b/src/Cake.7zip.Tests/SevenZipRunnerTests.cs @@ -92,7 +92,7 @@ public void Should_Access_registry() var sevenZipKey = new Mock(); sevenZipKey.Setup(k => k.GetValue("Path")).Returns(installLocation.Path.FullPath); - sevenZipKey.Setup(k => k.GetValue("Path64")).Returns(null); + sevenZipKey.Setup(k => k.GetValue("Path64")).Returns(null!); var softwareKey = new Mock(); softwareKey.Setup(k => k.OpenKey("7-Zip")).Returns(sevenZipKey.Object); var hklm = new Mock(); @@ -124,7 +124,7 @@ public void Should_Access_64bit_tool_from_registry() var file = fixture.FileSystem.CreateFile(installLocation.Path.CombineWithFilePath("7z.exe")); var sevenZipKey = new Mock(); - sevenZipKey.Setup(k => k.GetValue("Path")).Returns(null); + sevenZipKey.Setup(k => k.GetValue("Path")).Returns(null!); sevenZipKey.Setup(k => k.GetValue("Path64")).Returns(installLocation.Path.FullPath); var softwareKey = new Mock(); softwareKey.Setup(k => k.OpenKey("7-Zip")).Returns(sevenZipKey.Object); @@ -313,4 +313,4 @@ public void BuildArguments(ref ProcessArgumentBuilder builder) { // no-op } -} \ No newline at end of file +} diff --git a/src/Cake.7zip/Cake.7zip.csproj b/src/Cake.7zip/Cake.7zip.csproj index d8852be3..a7c0da15 100644 --- a/src/Cake.7zip/Cake.7zip.csproj +++ b/src/Cake.7zip/Cake.7zip.csproj @@ -1,6 +1,6 @@ - net6.0;net7.0;net8.0 + net8.0;net9.0 true true $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb @@ -39,8 +39,8 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive