From 1b921977a0ec3f012b73a0434bd4be2db5a60c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20Kapano=C4=9Flu?= Date: Tue, 22 Oct 2024 12:33:03 -0700 Subject: [PATCH 1/4] Fix the link for "Setting up a new project" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a980047230..6d625a9d20 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Cake (C# Make) is a build automation system with a C# DSL to do things like comp You can read the latest documentation at [https://cakebuild.net/](https://cakebuild.net/). -For a simple example to get started see [Setting up a new project](https://cakebuild.net/docs/getting-started/setting-up-a-new-project). +For a simple example to get started see [Setting up a new project](https://cakebuild.net/docs/getting-started/setting-up-a-new-scripting-project). ## Contributing From 795eed0f3486d70a7cd0d30e2f25fb7a7f9dd416 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Wed, 23 Oct 2024 18:44:34 +0200 Subject: [PATCH 2/4] (build) Updated Cake Tool to version 4.1.0 --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index da200cdae8..697280b6e3 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "4.0.0", + "version": "4.1.0", "commands": [ "dotnet-cake" ] From 5fae5cfc3fde01f14e372c816b0e675e4bbc9aba Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Wed, 23 Oct 2024 21:41:08 +0200 Subject: [PATCH 3/4] (GH-4374) Fix Frosting argument parsing * Add argument to Forsting integration tests * Unify Scripting / Frosting Spectre.Console IRemainingArguments to CakeArguments parsing * fixes #4374 --- build.cake | 3 +- .../Infrastructure/RemainingArgsParser.cs | 60 +++++++++++++++++++ .../Internal/Commands/DefaultCommand.cs | 27 +-------- src/Cake/Commands/DefaultCommand.cs | 33 ++++------ .../Cake.Frosting/build/Tasks/Hello.cs | 3 +- 5 files changed, 77 insertions(+), 49 deletions(-) create mode 100644 src/Cake.Cli/Infrastructure/RemainingArgsParser.cs diff --git a/build.cake b/build.cake index 7fe2d57077..d8132b7a55 100644 --- a/build.cake +++ b/build.cake @@ -342,7 +342,8 @@ Task("Frosting-Integration-Tests") DotNetRun(test.Project.FullPath, new ProcessArgumentBuilder() - .AppendSwitchQuoted("--verbosity", "=", "quiet"), + .AppendSwitchQuoted("--verbosity", "=", "quiet") + .AppendSwitchQuoted("--name", "=", "world"), new DotNetRunSettings { Configuration = parameters.Configuration, diff --git a/src/Cake.Cli/Infrastructure/RemainingArgsParser.cs b/src/Cake.Cli/Infrastructure/RemainingArgsParser.cs new file mode 100644 index 0000000000..6e77155a0f --- /dev/null +++ b/src/Cake.Cli/Infrastructure/RemainingArgsParser.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Cake.Core; +using Spectre.Console.Cli; + +namespace Cake.Cli.Infrastructure +{ + /// + /// Spectre.Console extensions. + /// + public static class IRemainingArgumentsExtensions + { + /// + /// Parses Spectre.Console to . + /// + /// The remainingArguments. + /// The optional targets, i.e. if specified by command. + /// The optional pre-process arguments. + /// . + public static CakeArguments ToCakeArguments( + this IRemainingArguments remainingArguments, + string[] targets = null, + Action>> preProcessArgs = null) + { + var arguments = new Dictionary>(StringComparer.OrdinalIgnoreCase); + + // Keep the actual remaining arguments in the cake arguments + foreach (var group in remainingArguments.Parsed) + { + string key = group.Key.TrimStart('-'); + arguments[key] = new List(); + foreach (var argument in group) + { + arguments[key].Add(argument); + } + } + + // Fixes #3291, We have to add arguments manually which are defined within the DefaultCommandSettings type. Those are not considered "as remaining" because they could be parsed + const string targetArgumentName = "target"; + if (!arguments.ContainsKey(targetArgumentName)) + { + arguments[targetArgumentName] = new List(); + } + + if (targets != null) + { + foreach (var target in targets) + { + arguments[targetArgumentName].Add(target); + } + } + + preProcessArgs?.Invoke(arguments); + + var argumentLookUp = arguments.SelectMany(a => a.Value, Tuple.Create).ToLookup(a => a.Item1.Key, a => a.Item2); + return new CakeArguments(argumentLookUp); + } + } +} diff --git a/src/Cake.Frosting/Internal/Commands/DefaultCommand.cs b/src/Cake.Frosting/Internal/Commands/DefaultCommand.cs index 6a172970a2..4541392419 100644 --- a/src/Cake.Frosting/Internal/Commands/DefaultCommand.cs +++ b/src/Cake.Frosting/Internal/Commands/DefaultCommand.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using Cake.Cli; +using Cake.Cli.Infrastructure; using Cake.Core; using Cake.Core.Diagnostics; using Cake.Core.IO; @@ -81,31 +82,7 @@ public override int Execute(CommandContext context, DefaultCommandSettings setti private static CakeArguments CreateCakeArguments(IRemainingArguments remainingArguments, DefaultCommandSettings settings) { - var arguments = new Dictionary>(StringComparer.OrdinalIgnoreCase); - - // Keep the actual remaining arguments in the cake arguments - foreach (var group in remainingArguments.Parsed) - { - arguments[group.Key] = new List(); - foreach (var argument in group) - { - arguments[group.Key].Add(argument); - } - } - - // Fixes #3291, We have to add arguments manually which are defined within the DefaultCommandSettings type. Those are not considered "as remaining" because they could be parsed - const string targetArgumentName = "target"; - if (!arguments.ContainsKey(targetArgumentName)) - { - arguments[targetArgumentName] = new List(); - } - foreach (var target in settings.Targets) - { - arguments[targetArgumentName].Add(target); - } - - var argumentLookUp = arguments.SelectMany(a => a.Value, Tuple.Create).ToLookup(a => a.Item1.Key, a => a.Item2); - return new CakeArguments(argumentLookUp); + return remainingArguments.ToCakeArguments(settings.Targets); } private void InstallTools(ServiceProvider provider) diff --git a/src/Cake/Commands/DefaultCommand.cs b/src/Cake/Commands/DefaultCommand.cs index dd3871f059..69d695bfc8 100644 --- a/src/Cake/Commands/DefaultCommand.cs +++ b/src/Cake/Commands/DefaultCommand.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using Cake.Cli; +using Cake.Cli.Infrastructure; using Cake.Core; using Cake.Core.Diagnostics; using Cake.Features.Bootstrapping; @@ -124,29 +125,17 @@ private int PerformBootstrapping(CommandContext context, DefaultCommandSettings private static CakeArguments CreateCakeArguments(IRemainingArguments remainingArguments, DefaultCommandSettings settings) { - var arguments = new Dictionary>(StringComparer.OrdinalIgnoreCase); - - // Keep the actual remaining arguments in the cake arguments - foreach (var group in remainingArguments.Parsed) - { - string key = group.Key.TrimStart('-'); - arguments[key] = new List(); - foreach (var argument in group) + return remainingArguments.ToCakeArguments( + preProcessArgs: arguments => { - arguments[key].Add(argument); - } - } - - // Fixes #4157, We have to add arguments manually which are defined within the DefaultCommandSettings type. Those are not considered "as remaining" because they could be parsed - const string recompileArgumentName = Infrastructure.Constants.Cache.InvalidateScriptCache; - if (settings.Recompile && !arguments.ContainsKey(recompileArgumentName)) - { - arguments[recompileArgumentName] = new List(); - arguments[recompileArgumentName].Add(true.ToString()); - } - - var argumentLookUp = arguments.SelectMany(a => a.Value, Tuple.Create).ToLookup(a => a.Item1.Key, a => a.Item2); - return new CakeArguments(argumentLookUp); + // Fixes #4157, We have to add arguments manually which are defined within the DefaultCommandSettings type. Those are not considered "as remaining" because they could be parsed + const string recompileArgumentName = Infrastructure.Constants.Cache.InvalidateScriptCache; + if (settings.Recompile && !arguments.ContainsKey(recompileArgumentName)) + { + arguments[recompileArgumentName] = new List(); + arguments[recompileArgumentName].Add(true.ToString()); + } + }); } } } diff --git a/tests/integration/Cake.Frosting/build/Tasks/Hello.cs b/tests/integration/Cake.Frosting/build/Tasks/Hello.cs index e01777b78e..95210218f5 100644 --- a/tests/integration/Cake.Frosting/build/Tasks/Hello.cs +++ b/tests/integration/Cake.Frosting/build/Tasks/Hello.cs @@ -1,3 +1,4 @@ +using Cake.Common; using Cake.Common.Diagnostics; using Cake.Frosting; @@ -6,6 +7,6 @@ public sealed class Hello : FrostingTask { public override void Run(Context context) { - context.Information("Hello World"); + context.Information("Hello {0}", context.Argument("name")); } } \ No newline at end of file From d2ed1def85fde617f1b4e61daee0d930372beb75 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Wed, 23 Oct 2024 22:27:52 +0200 Subject: [PATCH 4/4] (build) Updated version and release notes --- ReleaseNotes.md | 4 ++++ src/SolutionInfo.cs | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 920f591e47..1ded368f8c 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,3 +1,7 @@ +### New in 4.2.0 (Released 2024/10/23) + +* #4374 Argument 'foo' was not set" after update to 4.1 in Cake Frosting. + ### New in 4.1.0 (Released 2024/10/22) * 4353 Add DotNetListReference alias for dotnet list reference command. diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs index c8625c83d7..0b69dfd641 100644 --- a/src/SolutionInfo.cs +++ b/src/SolutionInfo.cs @@ -10,7 +10,7 @@ using System.Reflection; [assembly: AssemblyProduct("Cake")] -[assembly: AssemblyVersion("4.1.0.0")] -[assembly: AssemblyFileVersion("4.1.0.0")] -[assembly: AssemblyInformationalVersion("4.1.0-beta.1+0.Branch.release-4.1.0.Sha.a19ff93e1383ef8bc2fe0a1885a3fc011c60242e")] +[assembly: AssemblyVersion("4.2.0.0")] +[assembly: AssemblyFileVersion("4.2.0.0")] +[assembly: AssemblyInformationalVersion("4.2.0-beta.1+0.Branch.release-4.2.0.Sha.13fe6c38b31cfe8133e4cbfefc8518aedba42996")] [assembly: AssemblyCopyright("Copyright (c) .NET Foundation and Contributors")]