diff --git a/Cake.Recipe/Content/parameters.cake b/Cake.Recipe/Content/parameters.cake index 663fed73..c30cdac0 100644 --- a/Cake.Recipe/Content/parameters.cake +++ b/Cake.Recipe/Content/parameters.cake @@ -134,6 +134,7 @@ public static class BuildParameters public static bool ShouldDocumentSourceFiles { get; private set; } public static bool ShouldRunIntegrationTests { get; private set; } public static bool ShouldRunGitVersion { get; private set; } + public static bool ShouldUseTargetFrameworkPath { get; private set; } public static bool ShouldUseDeterministicBuilds { get @@ -383,6 +384,7 @@ public static class BuildParameters bool shouldBuildNugetSourcePackage = false, bool shouldRunIntegrationTests = false, bool? shouldRunGitVersion = null, + bool shouldUseTargetFrameworkPath = true, bool? transifexEnabled = null, TransifexMode transifexPullMode = TransifexMode.OnlyTranslated, int transifexPullPercentage = 60, @@ -473,6 +475,7 @@ public static class BuildParameters ShouldBuildNugetSourcePackage = shouldBuildNugetSourcePackage; ShouldRunGitVersion = shouldRunGitVersion ?? BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows; _shouldUseDeterministicBuilds = shouldUseDeterministicBuilds; + ShouldUseTargetFrameworkPath = shouldUseTargetFrameworkPath; MilestoneReleaseNotesFilePath = milestoneReleaseNotesFilePath ?? RootDirectoryPath.CombineWithFilePath("CHANGELOG.md"); FullReleaseNotesFilePath = fullReleaseNotesFilePath ?? RootDirectoryPath.CombineWithFilePath("ReleaseNotes.md"); diff --git a/Cake.Recipe/Content/setup.cake b/Cake.Recipe/Content/setup.cake index 5a1a7c13..3ae8c226 100644 --- a/Cake.Recipe/Content/setup.cake +++ b/Cake.Recipe/Content/setup.cake @@ -68,13 +68,10 @@ Setup(context => { settings.WithProperty("ContinuousIntegrationBuild", "true"); } - if (BuildParameters.BuildAgentOperatingSystem != PlatformFamily.Windows) + if (BuildParameters.ShouldUseTargetFrameworkPath && BuildParameters.BuildAgentOperatingSystem != PlatformFamily.Windows) { - // This needs to be updated when/if we ever starts supporting Cake .NET Core edition. - var frameworkPathOverride = new FilePath(typeof(object).Assembly.Location).GetDirectory().FullPath + "/"; - - context.Information("Will use FrameworkPathOverride={0} on .NET Core build related tasks since not building on Windows.", frameworkPathOverride); - settings.WithProperty("FrameworkPathOverride", frameworkPathOverride); + context.Information("Will use FrameworkPathOverride={0} on .NET Core build related tasks since not building on Windows.", ToolSettings.TargetFrameworkPathOverride); + settings.WithProperty("FrameworkPathOverride", ToolSettings.TargetFrameworkPathOverride); } return settings; diff --git a/Cake.Recipe/Content/toolsettings.cake b/Cake.Recipe/Content/toolsettings.cake index 547ff48c..b5678786 100644 --- a/Cake.Recipe/Content/toolsettings.cake +++ b/Cake.Recipe/Content/toolsettings.cake @@ -16,6 +16,7 @@ public static class ToolSettings public static MSBuildToolVersion BuildMSBuildToolVersion { get; private set; } public static int MaxCpuCount { get; private set; } public static DirectoryPath OutputDirectory { get; private set; } + public static string TargetFrameworkPathOverride { get; private set; } public static string CodecovTool { get; private set; } public static string CoverallsTool { get; private set; } @@ -94,6 +95,7 @@ public static class ToolSettings MSBuildToolVersion buildMSBuildToolVersion = MSBuildToolVersion.Default, int? maxCpuCount = null, DirectoryPath outputDirectory = null, + DirectoryPath targetFrameworkPathOverride = null, string[] dupFinderExcludeFilesByStartingCommentSubstring = null, int? dupFinderDiscardCost = null, bool? dupFinderThrowExceptionOnFindingDuplicates = null @@ -119,5 +121,22 @@ public static class ToolSettings BuildMSBuildToolVersion = buildMSBuildToolVersion; MaxCpuCount = maxCpuCount ?? 0; OutputDirectory = outputDirectory; + if (BuildParameters.ShouldUseTargetFrameworkPath && targetFrameworkPathOverride == null) + { + if (context.Environment.Runtime.IsCoreClr) + { + var path = context.Tools.Resolve("mono").GetDirectory(); + path = path.Combine("../lib/mono/4.5"); + TargetFrameworkPathOverride = path.FullPath + "/"; + } + else + { + TargetFrameworkPathOverride = new FilePath(typeof(object).Assembly.Location).GetDirectory().FullPath + "/"; + } + } + else + { + TargetFrameworkPathOverride = targetFrameworkPathOverride?.FullPath; + } } }