From 0eaee7e2a7d95611b1de58b40493f550ced31c78 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Tue, 24 Sep 2019 13:28:14 +0200 Subject: [PATCH] (GH-2603) Added .NET Core 3 moniker to Cake.Tool * Update SDK to .NET Core 3 (3.0.100) * Add netcoreapp3.0 moniker to Cake.Tool * Add netcoreapp3.0 moniker to Unit tests * Execute unit tests under netcoreapp3.0 * Consolidate Cake.Tool.csproj into Cake.csproj (sorts VS2019 rebuild issues) * Refactor Runtime Framework detection * Microsoft.CodeAnalysis.CSharp.Scripting 3.3.1 * Remove mono workaround * Add .NET Core rollForward policy * Build script cleanup * Update NuGet command line to 5.2.0 (5.3.0 not blessed yet) * Update NuGet Client libs to 5.3.0 * Temp fix for rollforward test * fixes #2603 --- .travis.yml | 2 +- build.cake | 49 ++++++------------ build.config | 2 +- build.ps1 | 9 ++-- build.sh | 10 ++-- global.json | 2 +- nuspec/cake-medium.png | Bin 0 -> 17063 bytes .../Cake.Common.Tests.csproj | 4 +- src/Cake.Core.Tests/Cake.Core.Tests.csproj | 2 +- .../Fixtures/ScriptRunnerFixture.cs | 3 +- src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs | 30 ++++++++++- .../Text/TextTransformationTemplateTests.cs | 2 +- src/Cake.Core/Polyfill/EnvironmentHelper.cs | 27 +++++++++- src/Cake.Core/Scripting/IScriptConventions.cs | 6 +++ src/Cake.Core/Scripting/ScriptConventions.cs | 43 ++++++++++++++- src/Cake.Core/Scripting/ScriptRunner.cs | 5 +- src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj | 2 +- src/Cake.NuGet/Cake.NuGet.csproj | 12 ++--- src/Cake.Tests/Cake.Tests.csproj | 4 +- src/Cake/Cake.Tool.csproj | 15 ------ src/Cake/Cake.csproj | 16 +++++- src/Cake/runtimeconfig.template.json | 5 ++ src/Shared.msbuild | 28 ++++------ .../TextTransform/TextTransformAliases.cake | 2 +- .../Cake.Core/Scripting/DefineDirective.cake | 39 +++++++++++++- tests/integration/setup.cake | 5 +- 26 files changed, 223 insertions(+), 101 deletions(-) create mode 100644 nuspec/cake-medium.png delete mode 100644 src/Cake/Cake.Tool.csproj create mode 100644 src/Cake/runtimeconfig.template.json diff --git a/.travis.yml b/.travis.yml index 38b1200c70..d19ef59f3e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ mono: - 5.12.0 - 5.20.1 -dotnet: 2.1.701 +dotnet: 3.0.100 before_install: - git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags diff --git a/build.cake b/build.cake index 40df02bc3a..585a2d6f0a 100644 --- a/build.cake +++ b/build.cake @@ -10,7 +10,7 @@ #tool "nuget:https://api.nuget.org/v3/index.json?package=coveralls.io&version=1.4.2" #tool "nuget:https://api.nuget.org/v3/index.json?package=OpenCover&version=4.6.519" #tool "nuget:https://api.nuget.org/v3/index.json?package=ReportGenerator&version=4.0.4" -#tool "nuget:https://api.nuget.org/v3/index.json?package=nuget.commandline&version=4.9.2" +#tool "nuget:https://api.nuget.org/v3/index.json?package=nuget.commandline&version=5.2.0" // Install .NET Core Global tools. #tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.0.1" @@ -165,33 +165,14 @@ Task("Build") Task("Run-Unit-Tests") .IsDependentOn("Build") - .Does(() => + .DoesForEach( + () => GetFiles("./src/**/*.Tests.csproj"), + project => { - var projects = GetFiles("./src/**/*.Tests.csproj"); - foreach(var project in projects) + foreach(var framework in new[] { "netcoreapp2.0", "netcoreapp3.0", "net461" }) { - var projectName = project.GetFilenameWithoutExtension().FullPath; - - FilePath - testResultsCore = MakeAbsolute(parameters.Paths.Directories.TestResults.CombineWithFilePath($"{projectName}_core_TestResults.xml")), - testResultsFull = MakeAbsolute(parameters.Paths.Directories.TestResults.CombineWithFilePath($"{projectName}_full_TestResults.xml")); - - // .NET Core - DotNetCoreTest(project.FullPath, new DotNetCoreTestSettings - { - Framework = "netcoreapp2.0", - NoBuild = true, - NoRestore = true, - Configuration = parameters.Configuration, - ArgumentCustomization = args=>args.Append($"--logger trx;LogFileName=\"{testResultsCore}\"") - }); - - // .NET Framework/Mono - // Total hack, but gets the work done. - var framework = "net46"; - if(project.ToString().EndsWith("Cake.Tests.csproj")) { - framework = "net461"; - } + FilePath testResultsPath = MakeAbsolute(parameters.Paths.Directories.TestResults + .CombineWithFilePath($"{project.GetFilenameWithoutExtension()}_{framework}_TestResults.xml")); DotNetCoreTest(project.FullPath, new DotNetCoreTestSettings { @@ -199,7 +180,7 @@ Task("Run-Unit-Tests") NoBuild = true, NoRestore = true, Configuration = parameters.Configuration, - ArgumentCustomization = args=>args.Append($"--logger trx;LogFileName=\"{testResultsFull}\"") + ArgumentCustomization = args=>args.Append($"--logger trx;LogFileName=\"{testResultsPath}\"") }); } }); @@ -403,11 +384,12 @@ Task("Create-NuGet-Packages") .ToArray() }); - DotNetCorePack("./src/Cake/Cake.Tool.csproj", new DotNetCorePackSettings { + DotNetCorePack("./src/Cake/Cake.csproj", new DotNetCorePackSettings { Configuration = parameters.Configuration, OutputDirectory = parameters.Paths.Directories.NuGetRoot, IncludeSymbols = true, - MSBuildSettings = msBuildSettings + MSBuildSettings = msBuildSettings, + ArgumentCustomization = arg => arg.Append("/p:PackAsTool=true") }); }); @@ -647,12 +629,13 @@ Task("Run-Integration-Tests") .IsDependentOn("Prepare-Integration-Tests") .DeferOnError() .DoesForEach( - ()=> new[] { - GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/Cake.dll").Single(), + () => new[] { + GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/netcoreapp2.1/**/Cake.dll").Single(), + GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/netcoreapp3.0/**/Cake.dll").Single(), parameters.Paths.Directories.IntegrationTestsBinFullFx.CombineWithFilePath("Cake.exe"), parameters.Paths.Directories.IntegrationTestsBinNetCore.CombineWithFilePath("Cake.dll") }, - cakeAssembly=> + cakeAssembly => { Information("Testing: {0}", cakeAssembly); CakeExecuteScript("./tests/integration/build.cake", @@ -700,7 +683,7 @@ Task("AppVeyor") }); Task("Travis") - .IsDependentOn("Run-Integration-Tests"); + .IsDependentOn("Run-Unit-Tests"); Task("ReleaseNotes") .IsDependentOn("Create-Release-Notes"); diff --git a/build.config b/build.config index d99a7192ee..a93ffb5b65 100644 --- a/build.config +++ b/build.config @@ -1,3 +1,3 @@ #!/usr/bin/env bash CAKE_VERSION=0.34.1 -DOTNET_VERSION=2.1.701 +DOTNET_VERSION=3.0.100 diff --git a/build.ps1 b/build.ps1 index fa3e3bb2b2..e48d09a09c 100755 --- a/build.ps1 +++ b/build.ps1 @@ -50,6 +50,11 @@ if ($PSVersionTable.PSEdition -ne 'Core') { # INSTALL .NET CORE CLI ########################################################################### +$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +$env:DOTNET_CLI_TELEMETRY_OPTOUT=1 +$env:DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2 + + Function Remove-PathVariable([string]$VariableToRemove) { $SplitChar = ';' @@ -103,10 +108,6 @@ if($FoundDotNetCliVersion -ne $DotNetVersion) { $env:DOTNET_ROOT=$InstallPath } -$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 -$env:DOTNET_CLI_TELEMETRY_OPTOUT=1 - - ########################################################################### # INSTALL CAKE ########################################################################### diff --git a/build.sh b/build.sh index 745cfa7f09..06bcee8070 100755 --- a/build.sh +++ b/build.sh @@ -20,6 +20,11 @@ fi # INSTALL .NET CORE CLI ########################################################################### +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +export DOTNET_CLI_TELEMETRY_OPTOUT=1 +export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 +export DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2 + DOTNET_INSTALLED_VERSION=$(dotnet --version 2>&1) if [ "$DOTNET_VERSION" != "$DOTNET_INSTALLED_VERSION" ]; then @@ -33,11 +38,6 @@ if [ "$DOTNET_VERSION" != "$DOTNET_INSTALLED_VERSION" ]; then export DOTNET_ROOT="$SCRIPT_DIR/.dotnet" fi -export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 -export DOTNET_CLI_TELEMETRY_OPTOUT=1 -export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 - - ########################################################################### # INSTALL CAKE ########################################################################### diff --git a/global.json b/global.json index 203466512b..052baf7d2d 100644 --- a/global.json +++ b/global.json @@ -3,6 +3,6 @@ "src" ], "sdk": { - "version": "2.1.701" + "version": "3.0.100" } } \ No newline at end of file diff --git a/nuspec/cake-medium.png b/nuspec/cake-medium.png new file mode 100644 index 0000000000000000000000000000000000000000..3093eb2621c523180a9d83d76cc52fe88defe726 GIT binary patch literal 17063 zcmZvEby$>7*zWGaA`J@CCDM}8T_WAx-6`EHB_iFON=Zs1wTMV}N_QjObzb~^=R5zL zy)Lc=cHWtJV(#aenfuvrB?UQ8iD4gREzsB$JaLHS5iqxX%}T4(&Bd9sbNx9#nYOrI+e~$Ah*9 z30N2McxtivsA>_VPR3uzAXCE-knGU&(k<2;vL3VlXtUS&XzKIVjNNB%`H3-FUo1Ae zwDG!>28I8BUcKRNmmBwi=g%X8n0L#pD^Ri)>Q$1e#PNAdEq%O?g#3;Ma=xLErsY*u zGDIFO)PGoGd>BqmP0bYLzn!zJ4;emg%WwGpgT_~(6IFd){U$bze|8-5_ysHd7z4$- z_{1&HTrbb5Exf(LAKN)_a1!Rt(KE(XHn^jRM!w|nnQeB|QJ2)+ZKS29u9ulF ze#X*fKv;bk&H0(88V(AFp8@$l9(xg6XGd&N$~RZmzPC`6FK zx7TAUO2SyfZZndF0C$Ru57w+}^_0Udc?yAm@8t!|z42R%FbELuWt zDJ8MSWTF$P<3VV6K1hrRr=|J2KT6siBiGeV8&v&$p(hIOQ>Ej3{B{2qdm~Fr!ci=! zIO7varkO=__ua4}Xly8kJtr5vn_JJm;Qf6a`;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!)P{wPxoH~K^TYG6RdQA>N=L7Ji2KQ9( zm^fN~t2=$HSlE)|XPrhv{Ot!V{j(t1p|^O%4hu7NsqMIcGR?+28}tq?N90pNAFnH# l*FDm)aQ?l<6O+Y`AN{uJgF64}oq&Lsw1mRD3NfRg{{#GAE;9fC literal 0 HcmV?d00001 diff --git a/src/Cake.Common.Tests/Cake.Common.Tests.csproj b/src/Cake.Common.Tests/Cake.Common.Tests.csproj index 7b7a569809..9cf23b7ad6 100644 --- a/src/Cake.Common.Tests/Cake.Common.Tests.csproj +++ b/src/Cake.Common.Tests/Cake.Common.Tests.csproj @@ -1,7 +1,7 @@  Cake.Common.Tests - net46;netcoreapp2.0 + net461;netcoreapp2.0;netcoreapp3.0 true true @@ -25,7 +25,7 @@ - + diff --git a/src/Cake.Core.Tests/Cake.Core.Tests.csproj b/src/Cake.Core.Tests/Cake.Core.Tests.csproj index 59285a5947..7452f2a596 100644 --- a/src/Cake.Core.Tests/Cake.Core.Tests.csproj +++ b/src/Cake.Core.Tests/Cake.Core.Tests.csproj @@ -1,7 +1,7 @@  Cake.Core.Tests - net46;netcoreapp2.0 + net461;netcoreapp2.0;netcoreapp3.0 true true diff --git a/src/Cake.Core.Tests/Fixtures/ScriptRunnerFixture.cs b/src/Cake.Core.Tests/Fixtures/ScriptRunnerFixture.cs index f87ee8525d..c82a17019f 100644 --- a/src/Cake.Core.Tests/Fixtures/ScriptRunnerFixture.cs +++ b/src/Cake.Core.Tests/Fixtures/ScriptRunnerFixture.cs @@ -57,9 +57,10 @@ public ScriptRunnerFixture(string fileName = "/Working/build.cake") Engine = Substitute.For(); Engine.CreateSession(Arg.Any()).Returns(Session); + var runtime = new CakeRuntime(); ScriptAnalyzer = new ScriptAnalyzer(FileSystem, Environment, Log, new[] { new FileLoadDirectiveProvider(Globber, Log) }); ScriptProcessor = Substitute.For(); - ScriptConventions = new ScriptConventions(FileSystem, AssemblyLoader); + ScriptConventions = new ScriptConventions(FileSystem, AssemblyLoader, runtime); var context = Substitute.For(); context.Environment.Returns(c => Environment); diff --git a/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs b/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs index b08bf91a92..ebd5c26acb 100644 --- a/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs +++ b/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs @@ -14,7 +14,7 @@ namespace Cake.Core.Tests.Unit { public sealed class CakeRuntimeTests { - public sealed class TheBuiltFrameworkroperty + public sealed class TheBuiltFrameworkProperty { [RuntimeFact(TestRuntime.CoreClr)] public void Should_Return_Correct_Result_For_CoreClr() @@ -26,7 +26,35 @@ public void Should_Return_Correct_Result_For_CoreClr() var framework = runtime.BuiltFramework; // Then +#if NETFRAMEWORK + Assert.Equal(".NETFramework,Version=v4.6.1", framework.FullName); +#elif !NETCOREAPP Assert.Equal(".NETStandard,Version=v2.0", framework.FullName); +#else + try + { + Assert.Equal(".NETCoreApp,Version=v" + + +#if NETCOREAPP2_0 + "2.0", +#elif NETCOREAPP2_1 + "2.1", +#elif NETCOREAPP2_2 + "2.2", +#elif NETCOREAPP3_0 + "3.0", +#endif + framework.FullName); + } + catch + { + // Temp fix for if only netcore3 installed + if (!StringComparer.Ordinal.Equals(framework.FullName, ".NETCoreApp,Version=v3.0")) + { + throw; + } + } +#endif } } diff --git a/src/Cake.Core.Tests/Unit/Text/TextTransformationTemplateTests.cs b/src/Cake.Core.Tests/Unit/Text/TextTransformationTemplateTests.cs index 8318305d41..c4f13ab9ac 100644 --- a/src/Cake.Core.Tests/Unit/Text/TextTransformationTemplateTests.cs +++ b/src/Cake.Core.Tests/Unit/Text/TextTransformationTemplateTests.cs @@ -52,7 +52,7 @@ public void Should_Throw_If_Key_Is_Empty(string key) // Then Assert.IsType(result); Assert.Equal("key", ((ArgumentException)result)?.ParamName); - Assert.Equal($"Key cannot be empty.", result.Message?.SplitLines()[0]); + Assert.StartsWith("Key cannot be empty", result.Message?.SplitLines()[0]); } [Theory] diff --git a/src/Cake.Core/Polyfill/EnvironmentHelper.cs b/src/Cake.Core/Polyfill/EnvironmentHelper.cs index e01a735c78..67b29a08b5 100644 --- a/src/Cake.Core/Polyfill/EnvironmentHelper.cs +++ b/src/Cake.Core/Polyfill/EnvironmentHelper.cs @@ -4,6 +4,8 @@ using System; #if NETCORE +using System.Linq; +using System.Reflection; using System.Runtime.InteropServices; #endif using System.Runtime.Versioning; @@ -15,7 +17,9 @@ internal static class EnvironmentHelper #if !NETCORE private static bool? _isRunningOnMac; #else + private static readonly FrameworkName NetStandardFramework = new FrameworkName(".NETStandard,Version=v2.0"); private static bool? _isCoreClr; + private static FrameworkName netCoreAppFramwork; #endif public static bool Is64BitOperativeSystem() @@ -119,7 +123,28 @@ public static Runtime GetRuntime() public static FrameworkName GetBuiltFramework() { #if NETCORE - return new FrameworkName(".NETStandard,Version=v2.0"); + if (netCoreAppFramwork != null) + { + return netCoreAppFramwork; + } + + var assemblyPath = typeof(System.Runtime.GCSettings)?.GetTypeInfo()?.Assembly?.CodeBase; + if (string.IsNullOrEmpty(assemblyPath)) + { + return NetStandardFramework; + } + + const string microsoftNetCoreApp = "Microsoft.NETCore.App"; + var runtimeBasePathLength = assemblyPath.IndexOf(microsoftNetCoreApp) + microsoftNetCoreApp.Length + 1; + var netCoreAppVersion = string.Concat(assemblyPath.Skip(runtimeBasePathLength).Take(3)); + if (string.IsNullOrEmpty(netCoreAppVersion)) + { + return NetStandardFramework; + } + + return netCoreAppFramwork = Version.TryParse(netCoreAppVersion, out var version) + ? new FrameworkName(".NETCoreApp", version) + : NetStandardFramework; #else return new FrameworkName(".NETFramework,Version=v4.6.1"); #endif diff --git a/src/Cake.Core/Scripting/IScriptConventions.cs b/src/Cake.Core/Scripting/IScriptConventions.cs index 2467a93391..c58e2a6091 100644 --- a/src/Cake.Core/Scripting/IScriptConventions.cs +++ b/src/Cake.Core/Scripting/IScriptConventions.cs @@ -25,5 +25,11 @@ public interface IScriptConventions /// The root to where to find Cake related assemblies. /// A list containing all default assemblies. IReadOnlyList GetDefaultAssemblies(DirectoryPath root); + + /// + /// Gets the default defines. + /// + /// A list containing all default defines. + IReadOnlyList GetDefaultDefines(); } } \ No newline at end of file diff --git a/src/Cake.Core/Scripting/ScriptConventions.cs b/src/Cake.Core/Scripting/ScriptConventions.cs index 31aa6096e2..b34c8db310 100644 --- a/src/Cake.Core/Scripting/ScriptConventions.cs +++ b/src/Cake.Core/Scripting/ScriptConventions.cs @@ -18,16 +18,19 @@ public sealed class ScriptConventions : IScriptConventions { private readonly IFileSystem _fileSystem; private readonly IAssemblyLoader _loader; + private readonly ICakeRuntime _runtime; /// /// Initializes a new instance of the class. /// /// The file system. /// The assembly loader. - public ScriptConventions(IFileSystem fileSystem, IAssemblyLoader loader) + /// The Cake runtime. + public ScriptConventions(IFileSystem fileSystem, IAssemblyLoader loader, ICakeRuntime runtime) { _fileSystem = fileSystem; _loader = loader; + _runtime = runtime; } /// @@ -106,6 +109,44 @@ public IReadOnlyList GetDefaultAssemblies(DirectoryPath root) return result.ToArray(); } + /// + /// Gets the default defines. + /// + /// A list containing all default defines. + public IReadOnlyList GetDefaultDefines() + { + return new[] + { + "#define CAKE", + _runtime.IsCoreClr ? "#define NETCOREAPP" : "#define NETFRAMEWORK", + $"#define {GetFrameworkDefine()}" + }; + } + + private string GetFrameworkDefine() + { + switch (_runtime.BuiltFramework.FullName) + { + case ".NETFramework,Version=v4.6.1": + return "NET461"; + + case ".NETCoreApp,Version=v2.0": + return "NETCOREAPP2_0"; + + case ".NETCoreApp,Version=v2.1": + return "NETCOREAPP2_1"; + + case ".NETCoreApp,Version=v2.2": + return "NETCOREAPP2_2"; + + case ".NETCoreApp,Version=v3.0": + return "NETCOREAPP3_0"; + + default: + return "NETSTANDARD2_0"; + } + } + private List LoadCakeAssemblies(DirectoryPath root) { var result = new List(); diff --git a/src/Cake.Core/Scripting/ScriptRunner.cs b/src/Cake.Core/Scripting/ScriptRunner.cs index cefde3c0ee..a2ee3db166 100644 --- a/src/Cake.Core/Scripting/ScriptRunner.cs +++ b/src/Cake.Core/Scripting/ScriptRunner.cs @@ -206,8 +206,11 @@ public void Run(IScriptHost host, FilePath scriptPath, IDictionary(result.Defines, StringComparer.Ordinal); + defines.AddRange(_conventions.GetDefaultDefines()); + // Execute the script. - var script = new Script(result.Namespaces, result.Lines, aliases, result.UsingAliases, result.UsingStaticDirectives, result.Defines); + var script = new Script(result.Namespaces, result.Lines, aliases, result.UsingAliases, result.UsingStaticDirectives, defines); session.Execute(script); } diff --git a/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj b/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj index 6defbe6567..7a6c844971 100644 --- a/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj +++ b/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj @@ -1,7 +1,7 @@  Cake.NuGet.Tests - net461;netcoreapp2.0 + net461;netcoreapp2.0;netcoreapp3.0 true true diff --git a/src/Cake.NuGet/Cake.NuGet.csproj b/src/Cake.NuGet/Cake.NuGet.csproj index c6aec6b52e..19ec400210 100644 --- a/src/Cake.NuGet/Cake.NuGet.csproj +++ b/src/Cake.NuGet/Cake.NuGet.csproj @@ -19,12 +19,12 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/src/Cake.Tests/Cake.Tests.csproj b/src/Cake.Tests/Cake.Tests.csproj index 41892348e0..3c4f885b6a 100644 --- a/src/Cake.Tests/Cake.Tests.csproj +++ b/src/Cake.Tests/Cake.Tests.csproj @@ -1,7 +1,7 @@  Cake.Tests - net461;netcoreapp2.0 + net461;netcoreapp2.0;netcoreapp3.0 true true @@ -24,7 +24,7 @@ - + diff --git a/src/Cake/Cake.Tool.csproj b/src/Cake/Cake.Tool.csproj deleted file mode 100644 index 45243478a2..0000000000 --- a/src/Cake/Cake.Tool.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - true - netcoreapp2.1 - dotnet-cake - - - - - - Cake.Tool - The Cake .NET Core Global Tool. - - - \ No newline at end of file diff --git a/src/Cake/Cake.csproj b/src/Cake/Cake.csproj index 7181dce07e..eeb1ef0591 100644 --- a/src/Cake/Cake.csproj +++ b/src/Cake/Cake.csproj @@ -1,12 +1,24 @@  Cake - net461;netcoreapp2.0 Exe AnyCpu true + netcoreapp2.1;netcoreapp3.0 + + + net461;netcoreapp2.0;$(TargetFrameworks); + + + + + Cake.Tool + dotnet-cake + The Cake .NET Core Global Tool. + + @@ -15,7 +27,7 @@ - + \ No newline at end of file diff --git a/src/Cake/runtimeconfig.template.json b/src/Cake/runtimeconfig.template.json new file mode 100644 index 0000000000..9336abc817 --- /dev/null +++ b/src/Cake/runtimeconfig.template.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://gist.githubusercontent.com/natemcmaster/0bdee16450f8ec1823f2c11af880ceeb/raw/runtimeconfig.template.schema.json", + // '2' allows for major-version roll-forward + "rollForwardOnNoCandidateFx": 2 +} \ No newline at end of file diff --git a/src/Shared.msbuild b/src/Shared.msbuild index d81e1f2a29..8718bde1cf 100644 --- a/src/Shared.msbuild +++ b/src/Shared.msbuild @@ -6,38 +6,32 @@ Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström, Dave Glick, Pascal Berger and contributors Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström, Dave Glick, Pascal Berger and contributors MIT - https://raw.githubusercontent.com/cake-build/graphics/master/png/cake-medium.png + cake-medium.png https://github.com/cake-build/cake git Cake;Script;Build https://cakebuild.net - - - 2.0.0 + + + + 2.0.0 + $(DefineConstants);NETCORE + portable + + + true - - - $(DefineConstants);NETCORE - portable - - - $(DefineConstants);NETCORE - portable - - - $(DefineConstants);NETCORE - portable - + false diff --git a/tests/integration/Cake.Common/Tools/TextTransform/TextTransformAliases.cake b/tests/integration/Cake.Common/Tools/TextTransform/TextTransformAliases.cake index a84b13edac..ad00262203 100644 --- a/tests/integration/Cake.Common/Tools/TextTransform/TextTransformAliases.cake +++ b/tests/integration/Cake.Common/Tools/TextTransform/TextTransformAliases.cake @@ -7,7 +7,7 @@ Task("Cake.Common.Tools.TextTransform.TextTransformAliases.TransformTemplate.Set var t4Path = Context.Tools.Resolve("t4") ?? Context.Tools.Resolve("t4.exe"); if (t4Path == null) { - DotNetCoreTool(null, "tool", "install --tool-path ./tools dotnet-t4 --version 2.0.2"); + DotNetCoreTool(null, "tool", "install --tool-path ./tools dotnet-t4 --version 2.0.5"); } }); diff --git a/tests/integration/Cake.Core/Scripting/DefineDirective.cake b/tests/integration/Cake.Core/Scripting/DefineDirective.cake index 4bd15e733f..3690c6b5fb 100644 --- a/tests/integration/Cake.Core/Scripting/DefineDirective.cake +++ b/tests/integration/Cake.Core/Scripting/DefineDirective.cake @@ -26,8 +26,45 @@ Task("Cake.Core.Scripting.DefineDirective.NotDefined") Assert.False(bar); }); +Task("Cake.Core.Scripting.DefineDirective.Runtime") + .Does(context => +{ +#if NETFRAMEWORK + Assert.Equal(".NETFramework,Version=v4.6.1", +#elif !NETCOREAPP + Assert.Equal(".NETStandard,Version=v2.0", +#else + Assert.Equal(".NETCoreApp,Version=v" + +#endif +#if NETCOREAPP2_0 + "2.0", +#elif NETCOREAPP2_1 + "2.1", +#elif NETCOREAPP2_2 + "2.2", +#elif NETCOREAPP3_0 + "3.0", +#endif + context.Environment.Runtime.BuiltFramework.FullName); +}); + +Task("Cake.Core.Scripting.DefineDirective.Cake") + .Does(() => +{ + bool cake; +#if (CAKE) + cake = true; +#else + cake = false; +#endif + Assert.True(cake); +}); + + ////////////////////////////////////////////////////////////////////////////// Task("Cake.Core.Scripting.DefineDirective") .IsDependentOn("Cake.Core.Scripting.DefineDirective.Defined") - .IsDependentOn("Cake.Core.Scripting.DefineDirective.NotDefined"); \ No newline at end of file + .IsDependentOn("Cake.Core.Scripting.DefineDirective.NotDefined") + .IsDependentOn("Cake.Core.Scripting.DefineDirective.Runtime") + .IsDependentOn("Cake.Core.Scripting.DefineDirective.Cake"); \ No newline at end of file diff --git a/tests/integration/setup.cake b/tests/integration/setup.cake index 039454c2c9..054881f263 100644 --- a/tests/integration/setup.cake +++ b/tests/integration/setup.cake @@ -17,11 +17,12 @@ Setup(setupContext => // Output information from setup task setupContext.Log.Information( Verbosity.Quiet, - "Performing setup initated by {0} ({1} tasks to be executed beginning with {2}, performing {3} build)", + "Performing setup initated by {0} ({1} tasks to be executed beginning with {2}, performing {3} build on {4})", setupContext.TargetTask?.Name, setupContext.TasksToExecute?.Count, setupContext.TasksToExecute?.Select(task => task.Name).FirstOrDefault(), - BuildSystem.Provider + BuildSystem.Provider, + setupContext.Environment.Runtime.BuiltFramework ); // Perform artifact cleanup