diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36b21caa63..3582bdf36b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,6 @@ stages: build_job: stage: build script: - - ln -s /usr/share/dotnet .dotnet - mkdir tools - ln -s /opt/nuget/nuget.exe ./tools - cake build.cake --target="Run-Unit-Tests" diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 20e7b8b6db..fdf57cd9d1 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,3 +1,7 @@ +### New in 0.26.0 (Released 2018/02/26) + +* 1781 Update to .NET Core 2 + ### New in 0.25.0 (Released 2018/01/17) * 1995 Make In-proc NuGet addin/tool installation default diff --git a/appveyor.yml b/appveyor.yml index 9c87453246..5adaa8c7da 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,5 @@ # Build script +image: Visual Studio 2017 init: - git config --global core.autocrlf true diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index aacbe930cb..10f8386426 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -5,7 +5,6 @@ pipelines: default: - step: script: - - ln -s /opt/dotnet .dotnet - mkdir tools - ln -s /opt/nuget/nuget.exe ./tools - cake --target="Run-Unit-Tests" diff --git a/build.cake b/build.cake index 3c3471fe54..a91f0d2ecb 100644 --- a/build.cake +++ b/build.cake @@ -4,7 +4,7 @@ #addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Gitter&version=0.7.0" // Install tools. -#tool "nuget:https://api.nuget.org/v3/index.json?package=gitreleasemanager&version=0.5.0" +#tool "nuget:https://api.nuget.org/v3/index.json?package=gitreleasemanager&version=0.7.0" #tool "nuget:https://api.nuget.org/v3/index.json?package=GitVersion.CommandLine&version=3.6.2" #tool "nuget:https://api.nuget.org/v3/index.json?package=coveralls.io&version=1.3.4" #tool "nuget:https://api.nuget.org/v3/index.json?package=OpenCover&version=4.6.519" @@ -139,6 +139,7 @@ Task("Build") DotNetCoreBuild(path.FullPath, new DotNetCoreBuildSettings() { Configuration = parameters.Configuration, + NoRestore = true, MSBuildSettings = msBuildSettings }); }); @@ -150,8 +151,29 @@ Task("Run-Unit-Tests") var projects = GetFiles("./src/**/*.Tests.csproj"); foreach(var project in projects) { - DotNetCoreTool(project, - "xunit", "--no-build -noshadow -configuration " + parameters.Configuration); + // .NET Core + DotNetCoreTest(project.ToString(), new DotNetCoreTestSettings + { + Framework = "netcoreapp2.0", + NoBuild = true, + NoRestore = true, + Configuration = parameters.Configuration + }); + + // .NET Framework/Mono + // Total hack, but gets the work done. + var framework = "net46"; + if(project.ToString().EndsWith("Cake.Tests.csproj")) { + framework = "net461"; + } + + DotNetCoreTest(project.ToString(), new DotNetCoreTestSettings + { + Framework = framework, + NoBuild = true, + NoRestore = true, + Configuration = parameters.Configuration + }); } }); @@ -163,6 +185,7 @@ Task("Copy-Files") DotNetCorePublish("./src/Cake", new DotNetCorePublishSettings { Framework = "net461", + NoRestore = true, VersionSuffix = parameters.Version.DotNetAsterix, Configuration = parameters.Configuration, OutputDirectory = parameters.Paths.Directories.ArtifactsBinFullFx, @@ -172,19 +195,20 @@ Task("Copy-Files") // .NET Core DotNetCorePublish("./src/Cake", new DotNetCorePublishSettings { - Framework = "netcoreapp1.0", + Framework = "netcoreapp2.0", + NoRestore = true, Configuration = parameters.Configuration, OutputDirectory = parameters.Paths.Directories.ArtifactsBinNetCore, MSBuildSettings = msBuildSettings }); // Copy license - CopyFileToDirectory("./LICENSE", parameters.Paths.Directories.ArtifactsBinFullFx); - CopyFileToDirectory("./LICENSE", parameters.Paths.Directories.ArtifactsBinNetCore); + CopyFileToDirectory("./LICENSE", parameters.Paths.Directories.ArtifactsBinFullFx); + CopyFileToDirectory("./LICENSE", parameters.Paths.Directories.ArtifactsBinNetCore); // Copy Cake.XML (since publish does not do this anymore) CopyFileToDirectory("./src/Cake/bin/" + parameters.Configuration + "/net461/Cake.xml", parameters.Paths.Directories.ArtifactsBinFullFx); - CopyFileToDirectory("./src/Cake/bin/" + parameters.Configuration + "/netcoreapp1.0/Cake.xml", parameters.Paths.Directories.ArtifactsBinNetCore); + CopyFileToDirectory("./src/Cake/bin/" + parameters.Configuration + "/netcoreapp2.0/Cake.xml", parameters.Paths.Directories.ArtifactsBinNetCore); }); Task("Zip-Files") @@ -243,6 +267,7 @@ Task("Create-NuGet-Packages") Configuration = parameters.Configuration, OutputDirectory = parameters.Paths.Directories.NugetRoot, NoBuild = true, + NoRestore = true, IncludeSymbols = true, MSBuildSettings = msBuildSettings }); diff --git a/build.ps1 b/build.ps1 index 268efee7fa..a30ce006ca 100644 --- a/build.ps1 +++ b/build.ps1 @@ -31,15 +31,12 @@ Param( [string[]]$ScriptArgs ) -$CakeVersion = "0.24.0" +$CakeVersion = "0.25.0" $DotNetChannel = "Current"; -$DotNetVersion = "1.1.7"; +$DotNetVersion = "2.1.4"; $DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1"; $NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -# Temporarily skip verification and opt-in to new in-proc NuGet -$ENV:CAKE_NUGET_USEINPROCESSCLIENT='true' - # Make sure tools folder exists $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent $ToolPath = Join-Path $PSScriptRoot "tools" diff --git a/build.sh b/build.sh index cbc2473d2d..a2bd590d59 100755 --- a/build.sh +++ b/build.sh @@ -10,12 +10,9 @@ SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) TOOLS_DIR=$SCRIPT_DIR/tools NUGET_EXE=$TOOLS_DIR/nuget.exe NUGET_URL=https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -CAKE_VERSION=0.24.0 +CAKE_VERSION=0.25.0 CAKE_EXE=$TOOLS_DIR/Cake.$CAKE_VERSION/Cake.exe -# Temporarily skip verification and opt-in to new in-proc NuGet -export CAKE_NUGET_USEINPROCESSCLIENT="true" - # Define default arguments. TARGET="Travis" CONFIGURATION="Release" @@ -50,7 +47,7 @@ if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then mkdir "$SCRIPT_DIR/.dotnet" fi curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://dot.net/v1/dotnet-install.sh -sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version 1.1.7 --install-dir .dotnet --no-path +sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version 2.1.4 --install-dir .dotnet --no-path export PATH="$SCRIPT_DIR/.dotnet":$PATH export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 export DOTNET_CLI_TELEMETRY_OPTOUT=1 diff --git a/build/paths.cake b/build/paths.cake index fb31f220f0..2d8829b964 100644 --- a/build/paths.cake +++ b/build/paths.cake @@ -25,7 +25,7 @@ public class BuildPaths var artifactsDir = (DirectoryPath)(context.Directory("./artifacts") + context.Directory("v" + semVersion)); var artifactsBinDir = artifactsDir.Combine("bin"); var artifactsBinFullFx = artifactsBinDir.Combine("net461"); - var artifactsBinNetCore = artifactsBinDir.Combine("netcoreapp1.0"); + var artifactsBinNetCore = artifactsBinDir.Combine("netcoreapp2.0"); var testResultsDir = artifactsDir.Combine("test-results"); var nugetRoot = artifactsDir.Combine("nuget"); diff --git a/global.json b/global.json index 0e81e338d3..d5d73c9b1e 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,8 @@ { - "projects": [ "src" ], + "projects": [ + "src" + ], "sdk": { - "version": "1.1.7" + "version": "2.1.4" } -} +} \ No newline at end of file diff --git a/nuspec/Cake.CoreCLR.symbols.nuspec b/nuspec/Cake.CoreCLR.symbols.nuspec index ef3cc760ef..3d680fd5fb 100644 --- a/nuspec/Cake.CoreCLR.symbols.nuspec +++ b/nuspec/Cake.CoreCLR.symbols.nuspec @@ -1,6 +1,6 @@ - - + + Cake.CoreCLR 0.0.0 Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström and contributors @@ -14,8 +14,8 @@ Cake Script Build - - - + + + \ No newline at end of file diff --git a/src/Cake.Common.Tests/Cake.Common.Tests.csproj b/src/Cake.Common.Tests/Cake.Common.Tests.csproj index 14cdee6e7c..6052fca65e 100644 --- a/src/Cake.Common.Tests/Cake.Common.Tests.csproj +++ b/src/Cake.Common.Tests/Cake.Common.Tests.csproj @@ -1,16 +1,12 @@  - Cake.Common.Tests - net46;netcoreapp1.0 - anycpu + net46;netcoreapp2.0 true true - - @@ -18,32 +14,25 @@ - - - - + + + - + + - - - - - - PreserveNewest - True @@ -51,7 +40,6 @@ Resources.resx - PublicResXFileCodeGenerator @@ -61,5 +49,4 @@ - - + \ No newline at end of file diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/MSBuild/DotNetCoreMSBuildSettingsExtensionsTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/MSBuild/DotNetCoreMSBuildSettingsExtensionsTests.cs index 845a569959..714ab22d40 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/MSBuild/DotNetCoreMSBuildSettingsExtensionsTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/MSBuild/DotNetCoreMSBuildSettingsExtensionsTests.cs @@ -782,7 +782,7 @@ public void Should_Return_The_Same_Configuration() public sealed class TheSetTargetFrameworkMethod { - private const string TargetFramework = "netstandard1.6"; + private const string TargetFramework = "netstandard2.0"; [Fact] public void Should_Set_Target_Framework() diff --git a/src/Cake.Common.Tests/Unit/XML/XmlTransformationTests.cs b/src/Cake.Common.Tests/Unit/XML/XmlTransformationTests.cs index 85c99243f9..710991d93a 100644 --- a/src/Cake.Common.Tests/Unit/XML/XmlTransformationTests.cs +++ b/src/Cake.Common.Tests/Unit/XML/XmlTransformationTests.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if !NETCORE using System.IO; using System.Linq; using System.Text; @@ -11,6 +10,7 @@ using Cake.Common.Xml; using Cake.Core; using Cake.Core.IO; +using Cake.Testing.Xunit; using Xunit; namespace Cake.Common.Tests.Unit.XML @@ -182,7 +182,8 @@ public void Should_Transform_Xml_String_And_Xsl_String_To_Result_String_With_Xml Assert.Equal(htm, result, ignoreLineEndingDifferences: true); } - [Fact] + // this feels wrong to be CLR only + [RuntimeFact(TestRuntime.Clr)] public void Should_Transform_Xml_String_And_Xsl_String_To_Result_String_With_Utf32Xml_Declaration() { // Given @@ -241,5 +242,4 @@ public void Should_Throw_If_String_Settings_Was_Null() } } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Cake.Common/Cake.Common.csproj b/src/Cake.Common/Cake.Common.csproj index beedeaefc5..ec080f992e 100644 --- a/src/Cake.Common/Cake.Common.csproj +++ b/src/Cake.Common/Cake.Common.csproj @@ -1,46 +1,30 @@  - Cake.Common - net46;netstandard1.6 + net46;netstandard2.0 Library AnyCpu true - Provides aliases (extension methods on Cake context) that support CI, build, unit tests, zip, signing, etc. for Cake. - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Cake.Common/Polyfill/XmlTransformationHelper.cs b/src/Cake.Common/Polyfill/XmlTransformationHelper.cs index fa484f0380..f86654f431 100644 --- a/src/Cake.Common/Polyfill/XmlTransformationHelper.cs +++ b/src/Cake.Common/Polyfill/XmlTransformationHelper.cs @@ -3,12 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Xml; - -#if !NETCORE using System.Xml.Xsl; -#else -using System; -#endif namespace Cake.Common.Polyfill { @@ -16,13 +11,9 @@ internal static class XmlTransformationHelper { public static void Transform(XmlReader xsl, XmlReader xml, XmlWriter result) { -#if NETCORE - throw new NotSupportedException("Not supported on .NET Core."); -#else var xslTransform = new XslCompiledTransform(); xslTransform.Load(xsl); xslTransform.Transform(xml, result); -#endif } } } diff --git a/src/Cake.Common/Polyfill/XmlWriterSettingsHelper.cs b/src/Cake.Common/Polyfill/XmlWriterSettingsHelper.cs index dbdee8c80d..b67561ef63 100644 --- a/src/Cake.Common/Polyfill/XmlWriterSettingsHelper.cs +++ b/src/Cake.Common/Polyfill/XmlWriterSettingsHelper.cs @@ -2,9 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if NETCORE -using System; -#endif using System.Xml; namespace Cake.Common.Polyfill @@ -13,20 +10,12 @@ internal static class XmlWriterSettingsHelper { public static bool GetDoNotEscapeUriAttributes(XmlWriterSettings settings) { -#if NETCORE - throw new NotSupportedException("Not supported on .NET Core."); -#else return settings.DoNotEscapeUriAttributes; -#endif } public static void SetDoNotEscapeUriAttributes(XmlWriterSettings settings, bool value) { -#if NETCORE - throw new NotSupportedException("Not supported on .NET Core."); -#else settings.DoNotEscapeUriAttributes = value; -#endif } } } diff --git a/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs b/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs index 4c604f9fe6..1ac29db230 100644 --- a/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs +++ b/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs @@ -244,7 +244,7 @@ public static void DotNetCoreBuild(this ICakeContext context, string project) /// /// var settings = new DotNetCoreBuildSettings /// { - /// Framework = "netcoreapp1.0", + /// Framework = "netcoreapp2.0", /// Configuration = "Debug", /// OutputDirectory = "./artifacts/" /// }; @@ -390,7 +390,7 @@ public static void DotNetCoreRun(this ICakeContext context, string project, Proc /// /// var settings = new DotNetCoreRunSettings /// { - /// Framework = "netcoreapp1.0", + /// Framework = "netcoreapp2.0", /// Configuration = "Release" /// }; /// @@ -444,7 +444,7 @@ public static void DotNetCorePublish(this ICakeContext context, string project) /// /// var settings = new DotNetCorePublishSettings /// { - /// Framework = "netcoreapp1.0", + /// Framework = "netcoreapp2.0", /// Configuration = "Release", /// OutputDirectory = "./artifacts/" /// }; @@ -614,7 +614,7 @@ public static void DotNetCoreClean(this ICakeContext context, string project) /// /// var settings = new DotNetCoreCleanSettings /// { - /// Framework = "netcoreapp1.0", + /// Framework = "netcoreapp2.0", /// Configuration = "Debug", /// OutputDirectory = "./artifacts/" /// }; diff --git a/src/Cake.Common/Xml/XmlPokeAliases.cs b/src/Cake.Common/Xml/XmlPokeAliases.cs index 5365a0dbb3..2cfa35a01f 100644 --- a/src/Cake.Common/Xml/XmlPokeAliases.cs +++ b/src/Cake.Common/Xml/XmlPokeAliases.cs @@ -568,13 +568,6 @@ private static XmlReaderSettings GetXmlReaderSettings(XmlPokeSettings settings) { var xmlReaderSettings = new XmlReaderSettings(); -#if NETCORE - if (settings.DtdProcessing == XmlDtdProcessing.Parse) - { - throw new CakeException("DtdProcessing is not available on .NET Core."); - } -#endif - xmlReaderSettings.DtdProcessing = (DtdProcessing)settings.DtdProcessing; return xmlReaderSettings; } diff --git a/src/Cake.Core.Tests/Cake.Core.Tests.csproj b/src/Cake.Core.Tests/Cake.Core.Tests.csproj index 7d1f80091e..59285a5947 100644 --- a/src/Cake.Core.Tests/Cake.Core.Tests.csproj +++ b/src/Cake.Core.Tests/Cake.Core.Tests.csproj @@ -1,42 +1,29 @@  - Cake.Core.Tests - net46;netcoreapp1.0 - AnyCpu + net46;netcoreapp2.0 true true - - - - - - + + + - + + - - - - - - - - - - + \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs b/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs index 5da001e161..b08bf91a92 100644 --- a/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs +++ b/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs @@ -14,32 +14,35 @@ namespace Cake.Core.Tests.Unit { public sealed class CakeRuntimeTests { - public sealed class TheTargetFrameworkProperty + public sealed class TheBuiltFrameworkroperty { - [RuntimeFact(TestRuntime.Clr)] - public void Should_Return_Correct_Result_For_Clr() + [RuntimeFact(TestRuntime.CoreClr)] + public void Should_Return_Correct_Result_For_CoreClr() { // Given var runtime = new CakeRuntime(); // When - var framework = runtime.TargetFramework; + var framework = runtime.BuiltFramework; // Then - Assert.Equal(".NETFramework,Version=v4.6.1", framework.FullName); + Assert.Equal(".NETStandard,Version=v2.0", framework.FullName); } + } - [RuntimeFact(TestRuntime.CoreClr)] - public void Should_Return_Correct_Result_For_CoreClr() + public sealed class TheExecutingFrameworkProperty + { + [RuntimeFact(TestRuntime.Clr)] + public void Should_Return_Correct_Result_For_Clr() { // Given var runtime = new CakeRuntime(); // When - var framework = runtime.TargetFramework; + var framework = runtime.BuiltFramework; // Then - Assert.Equal(".NETStandard,Version=v1.6", framework.FullName); + Assert.Equal(".NETFramework,Version=v4.6.1", framework.FullName); } } } diff --git a/src/Cake.Core/Cake.Core.csproj b/src/Cake.Core/Cake.Core.csproj index aca2b79726..1c00f5b027 100644 --- a/src/Cake.Core/Cake.Core.csproj +++ b/src/Cake.Core/Cake.Core.csproj @@ -1,30 +1,22 @@  - Cake.Core - net46;netstandard1.6 + net46;netstandard2.0 Library AnyCpu true - The Cake core library. - - - - - - - - + + + - @@ -33,9 +25,4 @@ - - - true - - \ No newline at end of file diff --git a/src/Cake.Core/CakeEnvironment.cs b/src/Cake.Core/CakeEnvironment.cs index 456117ef5b..f5ec34f49f 100644 --- a/src/Cake.Core/CakeEnvironment.cs +++ b/src/Cake.Core/CakeEnvironment.cs @@ -163,16 +163,6 @@ public DirectoryPath GetApplicationRoot() return ApplicationRoot; } - /// - /// Gets the target .Net framework version that the current AppDomain is targeting. - /// - /// The target framework. - [Obsolete("Please use CakeEnvironment.Runtime.TargetFramework instead.")] - public FrameworkName GetTargetFramework() - { - return Runtime.TargetFramework; - } - private static void SetWorkingDirectory(DirectoryPath path) { if (path.IsRelative) diff --git a/src/Cake.Core/CakeRuntime.cs b/src/Cake.Core/CakeRuntime.cs index 2bf7e6baa8..d55a7cf32c 100644 --- a/src/Cake.Core/CakeRuntime.cs +++ b/src/Cake.Core/CakeRuntime.cs @@ -14,9 +14,15 @@ namespace Cake.Core public sealed class CakeRuntime : ICakeRuntime { /// - /// Gets the target .NET framework version that the current AppDomain is targeting. + /// Gets the build-time .NET framework version that is being used. /// - public FrameworkName TargetFramework { get; } + public FrameworkName BuiltFramework { get; } + + /// + /// Gets the current executing .NET Runtime. + /// + /// The target framework. + public Runtime Runtime { get; } /// /// Gets the version of Cake executing the script. @@ -36,7 +42,8 @@ public sealed class CakeRuntime : ICakeRuntime /// public CakeRuntime() { - TargetFramework = EnvironmentHelper.GetFramework(); + BuiltFramework = EnvironmentHelper.GetBuiltFramework(); + Runtime = EnvironmentHelper.GetRuntime(); CakeVersion = AssemblyHelper.GetExecutingAssembly().GetName().Version; IsCoreClr = EnvironmentHelper.IsCoreClr(); } diff --git a/src/Cake.Core/Constants.cs b/src/Cake.Core/Constants.cs index d397f83290..d1e0d714a0 100644 --- a/src/Cake.Core/Constants.cs +++ b/src/Cake.Core/Constants.cs @@ -8,7 +8,7 @@ namespace Cake.Core { internal static class Constants { - public static readonly Version LatestBreakingChange = new Version(0, 22, 0); + public static readonly Version LatestBreakingChange = new Version(0, 26, 0); public static class Settings { diff --git a/src/Cake.Core/ICakeEnvironment.cs b/src/Cake.Core/ICakeEnvironment.cs index fd53edee66..7f87b26c6d 100644 --- a/src/Cake.Core/ICakeEnvironment.cs +++ b/src/Cake.Core/ICakeEnvironment.cs @@ -78,12 +78,5 @@ public interface ICakeEnvironment /// The application root path. [Obsolete("Please use ICakeEnvironment.ApplicationRoot instead.")] DirectoryPath GetApplicationRoot(); - - /// - /// Gets the target .Net framework version that the current AppDomain is targeting. - /// - /// The target framework. - [Obsolete("Please use ICakeEnvironment.Runtime.TargetFramework instead.")] - FrameworkName GetTargetFramework(); } } \ No newline at end of file diff --git a/src/Cake.Core/ICakeRuntime.cs b/src/Cake.Core/ICakeRuntime.cs index 05cd1f26eb..c425b502db 100644 --- a/src/Cake.Core/ICakeRuntime.cs +++ b/src/Cake.Core/ICakeRuntime.cs @@ -4,6 +4,7 @@ using System; using System.Runtime.Versioning; +using Cake.Core.Polyfill; namespace Cake.Core { @@ -13,10 +14,15 @@ namespace Cake.Core public interface ICakeRuntime { /// - /// Gets the target .NET framework version that the current AppDomain is targeting. + /// Gets the build-time .NET framework version that is being used. + /// + FrameworkName BuiltFramework { get; } + + /// + /// Gets the current executing .NET Runtime. /// /// The target framework. - FrameworkName TargetFramework { get; } + Runtime Runtime { get; } /// /// Gets the version of Cake executing the script. diff --git a/src/Cake.Core/Polyfill/AssemblyHelper.cs b/src/Cake.Core/Polyfill/AssemblyHelper.cs index b3b776554d..ef9e295676 100644 --- a/src/Cake.Core/Polyfill/AssemblyHelper.cs +++ b/src/Cake.Core/Polyfill/AssemblyHelper.cs @@ -5,7 +5,6 @@ using System; using System.Reflection; using Cake.Core.IO; - #if NETCORE using Cake.Core.Reflection; #endif @@ -34,7 +33,6 @@ public static Assembly LoadAssembly(AssemblyName assemblyName) public static Assembly LoadAssembly(ICakeEnvironment environment, IFileSystem fileSystem, FilePath path) { -#if NETCORE if (path == null) { throw new ArgumentNullException(nameof(path)); @@ -48,12 +46,7 @@ public static Assembly LoadAssembly(ICakeEnvironment environment, IFileSystem fi // Make the path absolute. path = path.MakeAbsolute(environment); - - var loader = new CakeAssemblyLoadContext(fileSystem, path.GetDirectory()); - return loader.LoadFromAssemblyPath(path.FullPath); -#else return Assembly.LoadFrom(path.FullPath); -#endif } } -} +} \ No newline at end of file diff --git a/src/Cake.Core/Polyfill/EnvironmentHelper.cs b/src/Cake.Core/Polyfill/EnvironmentHelper.cs index aa5c973cc1..e01a735c78 100644 --- a/src/Cake.Core/Polyfill/EnvironmentHelper.cs +++ b/src/Cake.Core/Polyfill/EnvironmentHelper.cs @@ -2,27 +2,27 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; #if NETCORE using System.Runtime.InteropServices; -#else -using System; #endif - using System.Runtime.Versioning; namespace Cake.Core.Polyfill { - internal class EnvironmentHelper + internal static class EnvironmentHelper { #if !NETCORE private static bool? _isRunningOnMac; +#else + private static bool? _isCoreClr; #endif public static bool Is64BitOperativeSystem() { #if NETCORE return RuntimeInformation.OSArchitecture == Architecture.X64 - || RuntimeInformation.OSArchitecture == Architecture.Arm64; + || RuntimeInformation.OSArchitecture == Architecture.Arm64; #else return Environment.Is64BitOperatingSystem; #endif @@ -31,17 +31,35 @@ public static bool Is64BitOperativeSystem() public static PlatformFamily GetPlatformFamily() { #if NETCORE - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + try { - return PlatformFamily.OSX; + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + return PlatformFamily.OSX; + } } - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + catch (PlatformNotSupportedException) { - return PlatformFamily.Linux; } - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + try + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + return PlatformFamily.Linux; + } + } + catch (PlatformNotSupportedException) + { + } + try + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return PlatformFamily.Windows; + } + } + catch (PlatformNotSupportedException) { - return PlatformFamily.Windows; } #else var platform = (int)Environment.OSVersion.Platform; @@ -68,7 +86,11 @@ public static PlatformFamily GetPlatformFamily() public static bool IsCoreClr() { #if NETCORE - return true; + if (_isCoreClr == null) + { + _isCoreClr = RuntimeInformation.FrameworkDescription.StartsWith(".NET Core"); + } + return _isCoreClr.Value; #else return false; #endif @@ -82,16 +104,25 @@ public static bool IsUnix() public static bool IsUnix(PlatformFamily family) { return family == PlatformFamily.Linux - || family == PlatformFamily.OSX; + || family == PlatformFamily.OSX; + } + + public static Runtime GetRuntime() + { + if (IsCoreClr()) + { + return Runtime.CoreClr; + } + return Runtime.Clr; } - public static FrameworkName GetFramework() + public static FrameworkName GetBuiltFramework() { #if NETCORE - return new FrameworkName(".NETStandard,Version=v1.6"); + return new FrameworkName(".NETStandard,Version=v2.0"); #else return new FrameworkName(".NETFramework,Version=v4.6.1"); #endif } } -} +} \ No newline at end of file diff --git a/src/Cake.Core/Polyfill/Runtime.cs b/src/Cake.Core/Polyfill/Runtime.cs new file mode 100644 index 0000000000..92cd4fa7e3 --- /dev/null +++ b/src/Cake.Core/Polyfill/Runtime.cs @@ -0,0 +1,18 @@ +namespace Cake.Core.Polyfill +{ + /// + /// The current Runtime Cake is executing on. + /// + public enum Runtime + { + /// + /// Full Framework or Mono. + /// + Clr, + + /// + /// .NET Core 2. + /// + CoreClr + } +} \ No newline at end of file diff --git a/src/Cake.Core/Reflection/CakeAssemblyLoadContext.cs b/src/Cake.Core/Reflection/CakeAssemblyLoadContext.cs deleted file mode 100644 index 6f4fb02028..0000000000 --- a/src/Cake.Core/Reflection/CakeAssemblyLoadContext.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if NETCORE -using System.Linq; -using System.Reflection; -using System.Runtime.Loader; -using Cake.Core.IO; -using Microsoft.Extensions.DependencyModel; - -namespace Cake.Core.Reflection -{ - internal class CakeAssemblyLoadContext : AssemblyLoadContext - { - private readonly IFileSystem _fileSystem; - private readonly DirectoryPath _root; - - public CakeAssemblyLoadContext(IFileSystem fileSystem, DirectoryPath root) - { - _fileSystem = fileSystem; - _root = root; - } - - protected override Assembly Load(AssemblyName assemblyName) - { - // Exists in default dependency context? - var context = DependencyContext.Default; - var library = context.CompileLibraries.FirstOrDefault(d => d.Name.Contains(assemblyName.Name)); - if (library != null) - { - // Load the assembly in the default assembly load context. - return Assembly.Load(new AssemblyName(library.Name)); - } - - // Does the file exist on disk? - var file = new FilePath(assemblyName.Name).ChangeExtension(".dll"); - var path = _root.CombineWithFilePath(file); - if (_fileSystem.Exist(path)) - { - // Try loading it in this context. - return LoadFromAssemblyPath(path.FullPath); - } - - // Load the assembly in the default assembly load context. - return Assembly.Load(assemblyName); - } - } -} -#endif \ No newline at end of file diff --git a/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj b/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj index 79cd825358..466feb9874 100644 --- a/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj +++ b/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj @@ -1,16 +1,12 @@  - Cake.NuGet.Tests - net46;netcoreapp1.0 - AnyCpu + net46;netcoreapp2.0 true true - - @@ -18,27 +14,22 @@ - - - - + + + - - - + + - - - - + \ No newline at end of file diff --git a/src/Cake.NuGet.Tests/Fixtures/NuGetAddinContentResolverFixture.cs b/src/Cake.NuGet.Tests/Fixtures/NuGetAddinContentResolverFixture.cs index 0ce1af363e..3f1193d2ef 100644 --- a/src/Cake.NuGet.Tests/Fixtures/NuGetAddinContentResolverFixture.cs +++ b/src/Cake.NuGet.Tests/Fixtures/NuGetAddinContentResolverFixture.cs @@ -7,13 +7,14 @@ using Cake.Core; using Cake.Core.IO; using Cake.Core.Packaging; +using Cake.Core.Polyfill; namespace Cake.NuGet.Tests.Fixtures { internal sealed class NuGetAddinContentResolverFixture : NuGetContentResolverFixture { - public NuGetAddinContentResolverFixture(string framework) - : base(framework) + public NuGetAddinContentResolverFixture(string framework, Runtime runtime) + : base(framework, runtime) { } } diff --git a/src/Cake.NuGet.Tests/Fixtures/NuGetContentResolverFixture.cs b/src/Cake.NuGet.Tests/Fixtures/NuGetContentResolverFixture.cs index 21c617e371..a413f217e6 100644 --- a/src/Cake.NuGet.Tests/Fixtures/NuGetContentResolverFixture.cs +++ b/src/Cake.NuGet.Tests/Fixtures/NuGetContentResolverFixture.cs @@ -7,6 +7,7 @@ using Cake.Core.Diagnostics; using Cake.Core.IO; using Cake.Core.Packaging; +using Cake.Core.Polyfill; using Cake.Testing; namespace Cake.NuGet.Tests.Fixtures @@ -22,10 +23,11 @@ internal abstract class NuGetContentResolverFixture public PackageType PackageType { get; set; } public PackageReference Package { get; set; } - protected NuGetContentResolverFixture(string framework) + protected NuGetContentResolverFixture(string framework, Runtime runtime) { Environment = FakeEnvironment.CreateUnixEnvironment(); - Environment.Runtime.TargetFramework = new FrameworkName(framework); + Environment.Runtime.BuiltFramework = new FrameworkName(framework); + Environment.Runtime.Runtime = runtime; FileSystem = new FakeFileSystem(Environment); Globber = new Globber(FileSystem, Environment); diff --git a/src/Cake.NuGet.Tests/Fixtures/NuGetToolContentResolverFixture.cs b/src/Cake.NuGet.Tests/Fixtures/NuGetToolContentResolverFixture.cs index 7796e44ce0..b8fe328746 100644 --- a/src/Cake.NuGet.Tests/Fixtures/NuGetToolContentResolverFixture.cs +++ b/src/Cake.NuGet.Tests/Fixtures/NuGetToolContentResolverFixture.cs @@ -7,13 +7,14 @@ using Cake.Core; using Cake.Core.IO; using Cake.Core.Packaging; +using Cake.Core.Polyfill; namespace Cake.NuGet.Tests.Fixtures { internal sealed class NuGetToolContentResolverFixture : NuGetContentResolverFixture { public NuGetToolContentResolverFixture(string uri) - : base(".NETFramework,Version=v4.5") + : base(".NETFramework,Version=v4.5", Runtime.Clr) { Package = new PackageReference(uri); PackageType = PackageType.Tool; diff --git a/src/Cake.NuGet.Tests/Unit/NuGetContentResolverTests.cs b/src/Cake.NuGet.Tests/Unit/NuGetContentResolverTests.cs index c10415eb3b..35b50cb0bf 100644 --- a/src/Cake.NuGet.Tests/Unit/NuGetContentResolverTests.cs +++ b/src/Cake.NuGet.Tests/Unit/NuGetContentResolverTests.cs @@ -4,6 +4,7 @@ using System.Linq; using Cake.Core.Diagnostics; +using Cake.Core.Polyfill; using Cake.NuGet.Tests.Fixtures; using Cake.Testing; using NSubstitute; @@ -117,7 +118,7 @@ public sealed class Addins public void Should_Throw_If_Path_Is_Null() { // Given - var fixture = new NuGetAddinContentResolverFixture(".NETStandard,Version=v1.6"); + var fixture = new NuGetAddinContentResolverFixture(".NETStandard,Version=v1.6", Runtime.CoreClr); fixture.Path = null; // When @@ -128,12 +129,12 @@ public void Should_Throw_If_Path_Is_Null() } [Theory] - [InlineData(".NETStandard,Version=v1.6", "netstandard1.6")] - [InlineData(".NETFramework,Version=v4.6.1", "net461")] - public void Should_Return_Exact_Framework_If_Possible(string framework, string expected) + [InlineData(".NETStandard,Version=v1.6", Runtime.CoreClr, "netstandard1.6")] + [InlineData(".NETFramework,Version=v4.6.1", Runtime.Clr, "net461")] + public void Should_Return_Exact_Framework_If_Possible(string framework, Runtime runtime, string expected) { // Given - var fixture = new NuGetAddinContentResolverFixture(framework); + var fixture = new NuGetAddinContentResolverFixture(framework, runtime); fixture.CreateCLRAssembly("/Working/lib/net45/file.dll"); fixture.CreateCLRAssembly("/Working/lib/net451/file.dll"); fixture.CreateCLRAssembly("/Working/lib/net452/file.dll"); @@ -152,12 +153,12 @@ public void Should_Return_Exact_Framework_If_Possible(string framework, string e } [Theory] - [InlineData(".NETStandard,Version=v1.6", "netstandard1.5")] - [InlineData(".NETFramework,Version=v4.6.1", "net452")] - public void Should_Return_Nearest_Compatible_Framework_If_An_Exact_Match_Is_Not_Possible(string framework, string expected) + [InlineData(".NETStandard,Version=v2.0", Runtime.CoreClr, "netstandard1.5")] + [InlineData(".NETFramework,Version=v4.6.1", Runtime.Clr, "net452")] + public void Should_Return_Nearest_Compatible_Framework_If_An_Exact_Match_Is_Not_Possible(string framework, Runtime runtime, string expected) { // Given - var fixture = new NuGetAddinContentResolverFixture(framework); + var fixture = new NuGetAddinContentResolverFixture(framework, runtime); fixture.CreateCLRAssembly("/Working/lib/net45/file.dll"); fixture.CreateCLRAssembly("/Working/lib/net451/file.dll"); fixture.CreateCLRAssembly("/Working/lib/net452/file.dll"); @@ -173,12 +174,12 @@ public void Should_Return_Nearest_Compatible_Framework_If_An_Exact_Match_Is_Not_ } [Theory] - [InlineData(".NETStandard,Version=v1.6")] - [InlineData(".NETFramework,Version=v4.6.1")] - public void Should_Return_Empty_Result_If_Any_Match_Is_Not_Possible(string framework) + [InlineData(".NETStandard,Version=v2.0", Runtime.CoreClr)] + [InlineData(".NETFramework,Version=v4.6.1", Runtime.Clr)] + public void Should_Return_Empty_Result_If_Any_Match_Is_Not_Possible(string framework, Runtime runtime) { // Given - var fixture = new NuGetAddinContentResolverFixture(framework); + var fixture = new NuGetAddinContentResolverFixture(framework, runtime); fixture.CreateCLRAssembly("/Working/lib/net462/file.dll"); fixture.CreateCLRAssembly("/Working/lib/netstandard2.2/file.dll"); @@ -194,7 +195,7 @@ public void Should_Return_Empty_Result_If_Any_Match_Is_Not_Possible(string frame public void Should_Return_Compatible_Netstandard_If_An_Exact_Match_Is_Not_Possible() { // Given - var fixture = new NuGetAddinContentResolverFixture(".NETFramework,Version=v4.6.1"); + var fixture = new NuGetAddinContentResolverFixture(".NETFramework,Version=v4.6.1", Runtime.Clr); fixture.CreateCLRAssembly("/Working/lib/netstandard1.0/file.dll"); fixture.CreateCLRAssembly("/Working/lib/netstandard1.3/file.dll"); @@ -213,7 +214,7 @@ public void Should_Return_Compatible_Netstandard_If_An_Exact_Match_Is_Not_Possib public void Should_Return_Only_CLR_Assemblies() { // Given - var fixture = new NuGetAddinContentResolverFixture(".NETStandard,Version=v1.6"); + var fixture = new NuGetAddinContentResolverFixture(".NETStandard,Version=v1.6", Runtime.CoreClr); fixture.CreateCLRAssembly("/Working/lib/netstandard1.6/file.dll"); fixture.CreateNonCLRAssembly("/Working/lib/netstandard1.6/lib/native.dll"); @@ -227,12 +228,12 @@ public void Should_Return_Only_CLR_Assemblies() } [Theory] - [InlineData(".NETStandard,Version=v1.6")] - [InlineData(".NETFramework,Version=v4.6.1")] - public void Should_Return_Files_When_Located_In_Root(string framework) + [InlineData(".NETStandard,Version=v1.6", Runtime.CoreClr)] + [InlineData(".NETFramework,Version=v4.6.1", Runtime.Clr)] + public void Should_Return_Files_When_Located_In_Root(string framework, Runtime runtime) { // Given - var fixture = new NuGetAddinContentResolverFixture(framework); + var fixture = new NuGetAddinContentResolverFixture(framework, runtime); fixture.CreateCLRAssembly("/Working/file1.dll"); fixture.CreateCLRAssembly("/Working/file2.dll"); @@ -249,12 +250,12 @@ public void Should_Return_Files_When_Located_In_Root(string framework) } [Theory] - [InlineData(".NETStandard,Version=v1.6", "netstandard1.6")] - [InlineData(".NETFramework,Version=v4.6.1", "net461")] - public void Should_Return_Exact_Framework_Even_Though_Files_Located_In_Root(string framework, string expected) + [InlineData(".NETStandard,Version=v1.6", Runtime.CoreClr, "netstandard1.6")] + [InlineData(".NETFramework,Version=v4.6.1", Runtime.Clr, "net461")] + public void Should_Return_Exact_Framework_Even_Though_Files_Located_In_Root(string framework, Runtime runtime, string expected) { // Given - var fixture = new NuGetAddinContentResolverFixture(framework); + var fixture = new NuGetAddinContentResolverFixture(framework, runtime); fixture.CreateCLRAssembly("/Working/lib/net461/file.dll"); fixture.CreateCLRAssembly("/Working/lib/netstandard1.6/file.dll"); @@ -269,12 +270,12 @@ public void Should_Return_Exact_Framework_Even_Though_Files_Located_In_Root(stri } [Theory] - [InlineData(".NETStandard,Version=v1.6")] - [InlineData(".NETFramework,Version=v4.6.1")] - public void Should_Return_From_Root_If_No_Compatible_Framework_Found(string framework) + [InlineData(".NETStandard,Version=v1.6", Runtime.CoreClr)] + [InlineData(".NETFramework,Version=v4.6", Runtime.Clr)] + public void Should_Return_From_Root_If_No_Compatible_Framework_Found(string framework, Runtime runtime) { // Given - var fixture = new NuGetAddinContentResolverFixture(framework); + var fixture = new NuGetAddinContentResolverFixture(framework, runtime); fixture.CreateCLRAssembly("/Working/lib/net462/file.dll"); fixture.CreateCLRAssembly("/Working/file.dll"); @@ -288,12 +289,12 @@ public void Should_Return_From_Root_If_No_Compatible_Framework_Found(string fram } [Theory] - [InlineData(".NETStandard,Version=v1.6")] - [InlineData(".NETFramework,Version=v4.6.1")] - public void Should_Log_Warning_For_Files_Located_In_Root(string framework) + [InlineData(".NETStandard,Version=v1.6", Runtime.CoreClr)] + [InlineData(".NETFramework,Version=v4.6.1", Runtime.Clr)] + public void Should_Log_Warning_For_Files_Located_In_Root(string framework, Runtime runtime) { // Given - var fixture = new NuGetAddinContentResolverFixture(framework); + var fixture = new NuGetAddinContentResolverFixture(framework, runtime); fixture.CreateCLRAssembly("/Working/file.dll"); fixture.CreateCLRAssembly("/Working/file2.dll"); @@ -312,12 +313,12 @@ public void Should_Log_Warning_For_Files_Located_In_Root(string framework) } [Theory] - [InlineData(".NETStandard,Version=v1.6")] - [InlineData(".NETFramework,Version=v4.6.1")] - public void Should_Not_Return_Ref_Assemblies(string framework) + [InlineData(".NETStandard,Version=v1.6", Runtime.CoreClr)] + [InlineData(".NETFramework,Version=v4.6.1", Runtime.Clr)] + public void Should_Not_Return_Ref_Assemblies(string framework, Runtime runtime) { // Given - var fixture = new NuGetAddinContentResolverFixture(framework); + var fixture = new NuGetAddinContentResolverFixture(framework, runtime); fixture.CreateCLRAssembly("/Working/ref/netstandard1.6/file.dll"); fixture.CreateCLRAssembly("/Working/ref/net46/file.dll"); diff --git a/src/Cake.NuGet/Cake.NuGet.csproj b/src/Cake.NuGet/Cake.NuGet.csproj index 27356eca22..e10366aefb 100644 --- a/src/Cake.NuGet/Cake.NuGet.csproj +++ b/src/Cake.NuGet/Cake.NuGet.csproj @@ -1,43 +1,34 @@  - Cake.NuGet - net46;netstandard1.6 + net46;netstandard2.0 Library AnyCpu true + $(NoWarn);NU1605 - Cake Module providing NuGet install capabilities for i.e. preprocessor directives like #addin, #tool and #load - - - - + + + + - - - - - - - - - + \ No newline at end of file diff --git a/src/Cake.NuGet/Install/NuGetPackageInstaller.cs b/src/Cake.NuGet/Install/NuGetPackageInstaller.cs index 145ef44a18..502ac860eb 100644 --- a/src/Cake.NuGet/Install/NuGetPackageInstaller.cs +++ b/src/Cake.NuGet/Install/NuGetPackageInstaller.cs @@ -64,7 +64,7 @@ public NuGetPackageInstaller( _contentResolver = contentResolver ?? throw new ArgumentNullException(nameof(contentResolver)); _log = log ?? throw new ArgumentNullException(nameof(log)); _config = config ?? throw new ArgumentNullException(nameof(config)); - _currentFramework = NuGetFramework.Parse(_environment.Runtime.TargetFramework.FullName, DefaultFrameworkNameProvider.Instance); + _currentFramework = NuGetFramework.Parse(_environment.Runtime.BuiltFramework.FullName, DefaultFrameworkNameProvider.Instance); _nugetLogger = new NuGetLogger(_log); var nugetConfig = GetNuGetConfigPath(_environment, _config); diff --git a/src/Cake.NuGet/NuGetContentResolver.cs b/src/Cake.NuGet/NuGetContentResolver.cs index a373bbdf4f..4b709672f9 100644 --- a/src/Cake.NuGet/NuGetContentResolver.cs +++ b/src/Cake.NuGet/NuGetContentResolver.cs @@ -61,7 +61,7 @@ private IReadOnlyCollection GetAddinAssemblies(DirectoryPath path, Packag // Get current framework. var provider = DefaultFrameworkNameProvider.Instance; - var current = NuGetFramework.Parse(_environment.Runtime.TargetFramework.FullName, provider); + var current = NuGetFramework.Parse(_environment.Runtime.BuiltFramework.FullName, provider); // Get all ref assemblies. var refAssemblies = _globber.GetFiles(path.FullPath + "/ref/**/*.dll"); @@ -99,7 +99,7 @@ private IReadOnlyCollection GetAddinAssemblies(DirectoryPath path, Packag if (nearest == NuGetFramework.AnyFramework) { - var framework = _environment.Runtime.TargetFramework; + var framework = _environment.Runtime.BuiltFramework; _log.Warning("Could not find any assemblies compatible with {0} in NuGet package {1}. " + "Falling back to using root folder of NuGet package.", framework.FullName, package.Package); } diff --git a/src/Cake.NuGet/NuGetPackageInstaller.cs b/src/Cake.NuGet/NuGetPackageInstaller.cs index e0d6d7753c..9e0de1deca 100644 --- a/src/Cake.NuGet/NuGetPackageInstaller.cs +++ b/src/Cake.NuGet/NuGetPackageInstaller.cs @@ -146,7 +146,7 @@ public IReadOnlyCollection Install(PackageReference package, PackageType { if (type == PackageType.Addin) { - var framework = _environment.Runtime.TargetFramework; + var framework = _environment.Runtime.BuiltFramework; _log.Warning("Could not find any assemblies compatible with {0}.", framework.FullName); } else if (type == PackageType.Tool) diff --git a/src/Cake.Testing.Xunit/Cake.Testing.Xunit.csproj b/src/Cake.Testing.Xunit/Cake.Testing.Xunit.csproj index 6f2d2eb412..699426e2a1 100644 --- a/src/Cake.Testing.Xunit/Cake.Testing.Xunit.csproj +++ b/src/Cake.Testing.Xunit/Cake.Testing.Xunit.csproj @@ -1,31 +1,18 @@  - Cake.Testing.Xunit - net46;netstandard1.6 + net46;netstandard2.0 Library AnyCpu - - - - + - - - - - - - - - \ No newline at end of file diff --git a/src/Cake.Testing.Xunit/RuntimeFact.cs b/src/Cake.Testing.Xunit/RuntimeFact.cs index 8617567951..7de3a549b4 100644 --- a/src/Cake.Testing.Xunit/RuntimeFact.cs +++ b/src/Cake.Testing.Xunit/RuntimeFact.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Cake.Core.Polyfill; using Xunit; namespace Cake.Testing.Xunit @@ -10,17 +11,15 @@ public sealed class RuntimeFact : FactAttribute { public RuntimeFact(TestRuntime runtime) { - if (runtime == TestRuntime.Clr) + if (runtime.HasFlag(TestRuntime.Clr) + && EnvironmentHelper.GetRuntime() != Runtime.Clr) { -#if NETCORE Skip = "Full framework test."; -#endif } - else if (runtime == TestRuntime.CoreClr) + else if (runtime.HasFlag(TestRuntime.CoreClr) + && EnvironmentHelper.GetRuntime() != Runtime.CoreClr) { -#if !NETCORE - Skip = ".NET Core test."; -#endif + Skip = ".NET Core 2 test."; } } } diff --git a/src/Cake.Testing.Xunit/RuntimeTheory.cs b/src/Cake.Testing.Xunit/RuntimeTheory.cs index 0d20e82615..74a7748ff8 100644 --- a/src/Cake.Testing.Xunit/RuntimeTheory.cs +++ b/src/Cake.Testing.Xunit/RuntimeTheory.cs @@ -10,13 +10,13 @@ public sealed class RuntimeTheory : TheoryAttribute { public RuntimeTheory(TestRuntime runtime) { - if (runtime == TestRuntime.Clr) + if (runtime.HasFlag(TestRuntime.Clr)) { #if NETCORE Skip = "Full framework test."; #endif } - else if (runtime == TestRuntime.CoreClr) + else if (runtime.HasFlag(TestRuntime.CoreClr)) { #if !NETCORE Skip = ".NET Core test."; diff --git a/src/Cake.Testing.Xunit/TestRuntime.cs b/src/Cake.Testing.Xunit/TestRuntime.cs index 225a9b8b87..2a8f658bf8 100644 --- a/src/Cake.Testing.Xunit/TestRuntime.cs +++ b/src/Cake.Testing.Xunit/TestRuntime.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; + namespace Cake.Testing.Xunit { public enum TestRuntime diff --git a/src/Cake.Testing/Cake.Testing.csproj b/src/Cake.Testing/Cake.Testing.csproj index 528828a650..e485cd8cc7 100644 --- a/src/Cake.Testing/Cake.Testing.csproj +++ b/src/Cake.Testing/Cake.Testing.csproj @@ -1,33 +1,19 @@  - Cake.Testing - net46;netstandard1.6 + net46;netstandard2.0 Library AnyCpu true - Contains testing utilities for Cake. - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/Cake.Testing/FakeEnvironment.cs b/src/Cake.Testing/FakeEnvironment.cs index 4b89339cb1..86f7e25f52 100644 --- a/src/Cake.Testing/FakeEnvironment.cs +++ b/src/Cake.Testing/FakeEnvironment.cs @@ -175,12 +175,12 @@ public void SetEnvironmentVariable(string variable, string value) } /// - /// Sets the target framework. + /// Sets the built framework. /// - /// The target framework. - public void SetTargetFramework(FrameworkName targetFramework) + /// The target framework. + public void SetBuiltFramework(FrameworkName builtFramework) { - Runtime.TargetFramework = targetFramework; + Runtime.BuiltFramework = builtFramework; } /// @@ -220,9 +220,9 @@ public DirectoryPath GetApplicationRoot() /// /// The target framework. [Obsolete("Please use FakeEnvironment.Runtime.TargetFramework instead.")] - public FrameworkName GetTargetFramework() + public FrameworkName GetBuiltFramework() { - return Runtime.TargetFramework; + return Runtime.BuiltFramework; } } } \ No newline at end of file diff --git a/src/Cake.Testing/FakeRuntime.cs b/src/Cake.Testing/FakeRuntime.cs index a165283f66..2a83ca7692 100644 --- a/src/Cake.Testing/FakeRuntime.cs +++ b/src/Cake.Testing/FakeRuntime.cs @@ -5,6 +5,7 @@ using System; using System.Runtime.Versioning; using Cake.Core; +using Cake.Core.Polyfill; namespace Cake.Testing { @@ -14,9 +15,15 @@ namespace Cake.Testing public sealed class FakeRuntime : ICakeRuntime { /// - /// Gets or sets the target .NET framework version that the current AppDomain is targeting. + /// Gets or sets the build-time .NET framework version that is being used. /// - public FrameworkName TargetFramework { get; set; } + public FrameworkName BuiltFramework { get; set; } + + /// + /// Gets or sets the current executing .NET Runtime. + /// + /// The target framework. + public Runtime Runtime { get; set; } /// /// Gets or sets the version of Cake executing the script. @@ -36,7 +43,8 @@ public sealed class FakeRuntime : ICakeRuntime /// public FakeRuntime() { - TargetFramework = new FrameworkName(".NETFramework,Version=v4.5"); + BuiltFramework = new FrameworkName(".NETFramework,Version=v4.6.2"); + Runtime = Runtime.Clr; CakeVersion = new Version(0, 1, 2); IsCoreClr = false; } diff --git a/src/Cake.Tests/Cake.Tests.csproj b/src/Cake.Tests/Cake.Tests.csproj index 3553808bb2..41892348e0 100644 --- a/src/Cake.Tests/Cake.Tests.csproj +++ b/src/Cake.Tests/Cake.Tests.csproj @@ -1,16 +1,12 @@  - Cake.Tests - net461;netcoreapp1.0 - AnyCpu + net461;netcoreapp2.0 true true - - @@ -18,26 +14,23 @@ - - - - + + + - + + - - + - - - + \ No newline at end of file diff --git a/src/Cake.sln.DotSettings b/src/Cake.sln.DotSettings index 099fcce4b2..8c64a35633 100644 --- a/src/Cake.sln.DotSettings +++ b/src/Cake.sln.DotSettings @@ -17,6 +17,8 @@ ERROR DO_NOT_SHOW DO_NOT_SHOW + NEVER + NEVER LINE_BREAK True CI @@ -35,7 +37,11 @@ VSTS <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /> True + True + True + True True + True True True True diff --git a/src/Cake/App.config b/src/Cake/App.config deleted file mode 100644 index 731f6de6c2..0000000000 --- a/src/Cake/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/Cake/Cake.csproj b/src/Cake/Cake.csproj index 54e67174a3..8123d068a8 100644 --- a/src/Cake/Cake.csproj +++ b/src/Cake/Cake.csproj @@ -1,43 +1,21 @@  - Cake - net461;netcoreapp1.0 + net461;netcoreapp2.0 Exe AnyCpu true - - - + - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/Cake/Composition/ContainerRegistrar.cs b/src/Cake/Composition/ContainerRegistrar.cs index d8e1697d83..a38e27c789 100644 --- a/src/Cake/Composition/ContainerRegistrar.cs +++ b/src/Cake/Composition/ContainerRegistrar.cs @@ -43,7 +43,9 @@ public IContainer Build() public void Update(IContainer container) { +#pragma warning disable CS0618 _builder.Update(container); +#pragma warning restore CS0618 } } } \ No newline at end of file diff --git a/src/Cake/Composition/ModuleLoader.cs b/src/Cake/Composition/ModuleLoader.cs index 3cd0d3055d..41c1603e60 100644 --- a/src/Cake/Composition/ModuleLoader.cs +++ b/src/Cake/Composition/ModuleLoader.cs @@ -58,7 +58,10 @@ private void RegisterExternalModules(IEnumerable moduleTypes, ILifetimeSco _log.Debug("Registering module {0}...", moduleType.FullName); builder.RegisterType(moduleType).As().SingleInstance(); } + +#pragma warning disable CS0618 builder.Update(scope.ComponentRegistry); +#pragma warning restore CS0618 } } } \ No newline at end of file diff --git a/src/Shared.msbuild b/src/Shared.msbuild index 888712288b..fb80c6adef 100644 --- a/src/Shared.msbuild +++ b/src/Shared.msbuild @@ -1,6 +1,5 @@ - - + $(AssemblyName) Copyright (c) .NET Foundation and contributors @@ -12,34 +11,27 @@ git Cake;Script;Build - - $(PackageTargetFallback);dnxcore50 - $(PackageTargetFallback);dnxcore50 - 1.0.9 - 1.6.0 + 2.0.0 - - true - - + $(DefineConstants);NETCORE + portable - + $(DefineConstants);NETCORE portable - false @@ -50,17 +42,20 @@ false false - $(MSBuildThisFileDirectory)Cake.ruleset $(MSBuildThisFileDirectory)Test.ruleset + + + PreserveNewest + + All - - \ No newline at end of file + diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs index b1e25621d6..83006dbeac 100644 --- a/src/SolutionInfo.cs +++ b/src/SolutionInfo.cs @@ -10,7 +10,7 @@ using System.Reflection; [assembly: AssemblyProduct("Cake")] -[assembly: AssemblyVersion("0.25.0.0")] -[assembly: AssemblyFileVersion("0.25.0.0")] -[assembly: AssemblyInformationalVersion("0.25.0-beta.1+0.Branch.release/0.25.0.Sha.796f60fdc81967e6497a8d525b600e0b93a117c4")] +[assembly: AssemblyVersion("0.26.0.0")] +[assembly: AssemblyFileVersion("0.26.0.0")] +[assembly: AssemblyInformationalVersion("0.26.0-beta.1+0.Branch.release/0.26.0.Sha.717c56ae2c1e132d53cf213534b81fde117d3b7e")] [assembly: AssemblyCopyright("Copyright (c) .NET Foundation and Contributors")] \ No newline at end of file diff --git a/src/xunit.runner.json b/src/xunit.runner.json new file mode 100644 index 0000000000..5558408fd5 --- /dev/null +++ b/src/xunit.runner.json @@ -0,0 +1 @@ +{ "appDomain": "denied" } \ No newline at end of file diff --git a/tests/integration/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cake b/tests/integration/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cake index 9fa128dbb7..efafd37546 100644 --- a/tests/integration/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cake +++ b/tests/integration/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cake @@ -34,7 +34,7 @@ Task("Cake.Common.Tools.DotNetCore.DotNetCoreAliases.DotNetCoreBuild") // Given var path = Paths.Temp.Combine("./Cake.Common/Tools/DotNetCore"); var project = path.CombineWithFilePath("hwapp/hwapp.csproj"); - var assembly = path.CombineWithFilePath("hwapp/bin/Debug/netcoreapp1.0/hwapp.dll"); + var assembly = path.CombineWithFilePath("hwapp/bin/Debug/netcoreapp2.0/hwapp.dll"); // When DotNetCoreBuild(project.FullPath); @@ -122,7 +122,7 @@ Task("Cake.Common.Tools.DotNetCore.DotNetCoreAliases.DotNetCoreExecute") { // Given var path = Paths.Temp.Combine("./Cake.Common/Tools/DotNetCore"); - var assembly = path.CombineWithFilePath("hwapp/bin/Debug/netcoreapp1.0/hwapp.dll"); + var assembly = path.CombineWithFilePath("hwapp/bin/Debug/netcoreapp2.0/hwapp.dll"); // When DotNetCoreExecute(assembly); diff --git a/tests/integration/build.ps1 b/tests/integration/build.ps1 index 7db3f14445..b37f4015c8 100644 --- a/tests/integration/build.ps1 +++ b/tests/integration/build.ps1 @@ -55,7 +55,7 @@ $Script = (Join-Path $PSScriptRoot "windows.cake") $ToolsPath = Join-Path $PSScriptRoot "tools" $NuGetPath = Join-Path $ToolsPath "nuget.exe" $DotNetChannel = "Current" -$DotNetVersion = "1.1.7"; +$DotNetVersion = "2.1.4"; $DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1"; $NuGetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" diff --git a/tests/integration/build.sh b/tests/integration/build.sh index d029321194..5e401bf265 100755 --- a/tests/integration/build.sh +++ b/tests/integration/build.sh @@ -61,7 +61,7 @@ if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then mkdir "$SCRIPT_DIR/.dotnet" fi curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://dot.net/v1/dotnet-install.sh -sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version 1.1.7 --install-dir .dotnet --no-path +sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version 2.1.4 --install-dir .dotnet --no-path export PATH="$SCRIPT_DIR/.dotnet":$PATH export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 export DOTNET_CLI_TELEMETRY_OPTOUT=1 diff --git a/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp.common/hwapp.common.csproj b/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp.common/hwapp.common.csproj index c02d7d5dd4..9c5cdecc4f 100644 --- a/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp.common/hwapp.common.csproj +++ b/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp.common/hwapp.common.csproj @@ -1,11 +1,9 @@  - - netstandard1.6 + netstandard2.0 portable hwapp.common hwapp.common 1.6.0 - - + \ No newline at end of file diff --git a/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp.tests/hwapp.tests.csproj b/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp.tests/hwapp.tests.csproj index d740a27f8d..961744ce1e 100644 --- a/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp.tests/hwapp.tests.csproj +++ b/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp.tests/hwapp.tests.csproj @@ -1,23 +1,18 @@  - - netcoreapp1.0 + netcoreapp2.0 portable hwapp.tests hwapp.tests true - $(PackageTargetFallback);dotnet5.4;portable-net451+win8 - 1.0.9 + 2.0.0 - - - - - - + + + + - - + \ No newline at end of file diff --git a/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp/hwapp.csproj b/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp/hwapp.csproj index 30d691fb30..927e3677f0 100644 --- a/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp/hwapp.csproj +++ b/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp/hwapp.csproj @@ -1,17 +1,13 @@  - - netcoreapp1.0 + netcoreapp2.0 portable hwapp Exe hwapp - $(PackageTargetFallback);dnxcore50 - 1.0.9 + 2.0.0 - - - + \ No newline at end of file diff --git a/tests/integration/utilities/xunit.cake b/tests/integration/utilities/xunit.cake index 10aa073a64..ff03038a81 100644 --- a/tests/integration/utilities/xunit.cake +++ b/tests/integration/utilities/xunit.cake @@ -1,4 +1,4 @@ -#addin "nuget:?package=xunit.assert&version=2.2.0-beta2-build3300&prerelease" +#addin "nuget:?package=xunit.assert&version=2.3.1&prerelease" // Usings using Xunit;