- Published
- Saturday, 28 September 2019
- Category
- Release Notes
- Author
- devlead
Version 0.35.0 of Cake has been released.
We're truly excited by this release which has some amazing features and improvements!
In this blog post we'll highlight:
- .NET Core 3 support
- C# 8
- Runtime identification & compiler constants
Contributions were included from:
- devlead
- GeertvanHorrik
- patriksvensson
- gep13
- kcamp
- agc93
- arturcic
- fruffin
- Roadrunner67
- pritchums
- RehanSaeed
Full details of everything that was included in this release can be seen below.
.NET Core 3 support
Cake.Tool is now, in addition to .NET Core 2.1, also compiled for .NET Core 3.0 using .NET Core 3 RTM SDK.
This means Cake is built and tested to be able to run without modification in a pure .NET Core 3 environment.
Installing Cake.Tool
dotnet tool install --global Cake.Tool --version 0.35.0
Executing Cake.Tool
dotnet cake build.cake
C# 8
Cake now ships with Roslyn 3.3.1, which will provide C# 8 support in your Cake scripts when running Cake.Tool on .NET Core 3.
Example C# 8
// Switch expression
static string ToLevel(this Verbosity verbosity)
=> verbosity switch
{
Verbosity.Diagnostic => "[****]",
Verbosity.Verbose => "[*** ]",
Verbosity.Normal => "[** ]",
Verbosity.Minimal => "[* ]",
Verbosity.Quiet => "[ ]",
_ => throw new ArgumentOutOfRangeException(message: "invalid enum value",
actualValue: verbosity,
paramName: nameof(verbosity)),
};
Verbosity[] verbosities = null;
// Null-coalescing assignment
verbosities ??= (Verbosity[])Enum.GetValues(typeof(Verbosity));
// Range last 4
foreach(Verbosity verbosity in verbosities[^4..])
{
Information(
"{0} = {1:F}",
verbosity.ToLevel(),
verbosity
);
}
Output
[* ] = Minimal
[** ] = Normal
[*** ] = Verbose
[****] = Diagnostic
Runtime identification & compiler constants
Runtime identification and detection has been improved, so now Cake will not just compile scripts as .NET Standard but the actual .NET Core runtime it's running under. This for example means Cake can now fully utilize a NuGet package compiled for .NET Core 3.
As Cake will now have different language features depending on which .NET Framework / Runtime it's running under we've introduced the same preprocessor symbols you generally get in regular C# with one Cake specific addition.
Symbols | Framework | Cake Runner |
---|---|---|
NET461 |
.NET Framework and Mono | Cake |
NETCOREAPP2_0 |
.NET Core 2.0 | Cake.CoreCLR |
NETCOREAPP2_1 |
.NET Core 2.1 | Cake.Tool |
NETCOREAPP2_2 |
.NET Core 2.2 | Cake.Tool |
NETCOREAPP3_0 |
.NET Core 3.0 | Cake.Tool |
NETSTANDARD2_0 |
.NET Standard | default for unknown / new runtimes |
NETCOREAPP |
.NET Core (any version) | Cake.Tool / Cake.CoreCLR |
NETFRAMEWORK |
.NET Framework and Mono | Cake |
CAKE |
Executing with Cake | Cake / Cake.Tool / Cake.CoreCLR |
This lets you if needed detect and adapt script based on runtime at script compile time.
Example Usage
#if (CAKE)
Information("Running on Cake.");
#else
Console.WriteLine("Not running on Cake.");
#endif
#if NETFRAMEWORK
Information("Running on .NET Framework.");
#elif NETCOREAPP
Information("Running on .NET Core.");
#else
Information("Running on something else.");
#endif
#if NETCOREAPP3_0
Information("Running on .NET Core 3.0.");
#endif
Issues
As part of this release we had 10 issues closed.
Features
- #2603 Add .NET Core 3 to Cake.Tool update to .NET Core 3 SDK.
Improvements
- #2625 Add NuGet Push -SkipDuplicate Flag.
- #2618 The MSTest tool doesn't pick up the mstest.exe from Visual Studio 2019.
- #2606 Unable to reference Newtonsoft.Json > 11.0.2.
- #2601 Update Microsoft.CodeAnalysis.CSharp.Scripting to 3.2.1.
- #2599 Update to Autofac 4.9.4.
- #2585 Cake.Tool - How in the world do I run a specific task?.
Documentation
- #2590 Update confusing GitVersionVerbosity docs.
Bugs
- #2610 Aliases of type 'dynamic' cannot be accessed directly.
- #2608 TFBuildProvider.IsHostedAgent returns wrong value when running on 2nd build agent.