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"
]
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
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/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/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")]
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