From 0c2d090a8b3e6db6e079d2348f5f1fa749b19cb2 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sat, 27 Jun 2020 10:09:44 +0100 Subject: [PATCH 01/14] (GH-81) Run GitVersion everywhere Remove the if statement which was preventing the execution of GitVersion on anything but Windows. --- build/Utilities/BuildVersion.cs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/build/Utilities/BuildVersion.cs b/build/Utilities/BuildVersion.cs index 3f9c0ec..f648c8a 100644 --- a/build/Utilities/BuildVersion.cs +++ b/build/Utilities/BuildVersion.cs @@ -31,28 +31,25 @@ public static BuildVersion Calculate(Context context) string assemblySemVer = null; string fullSemVersion = null; - if (context.IsRunningOnWindows()) + context.Information("Calculating semantic version..."); + if (!context.IsLocalBuild) { - context.Information("Calculating semantic version..."); - if (!context.IsLocalBuild) + context.GitVersion(new GitVersionSettings { - context.GitVersion(new GitVersionSettings - { - OutputType = GitVersionOutput.BuildServer - }); - } - - GitVersion assertedVersions = context.GitVersion(new GitVersionSettings - { - OutputType = GitVersionOutput.Json + OutputType = GitVersionOutput.BuildServer }); - version = assertedVersions.MajorMinorPatch; - semVersion = assertedVersions.LegacySemVerPadded; + } + + GitVersion assertedVersions = context.GitVersion(new GitVersionSettings + { + OutputType = GitVersionOutput.Json + }); + version = assertedVersions.MajorMinorPatch; + semVersion = assertedVersions.LegacySemVerPadded; informationalVersion = assertedVersions.InformationalVersion; assemblySemVer = assertedVersions.AssemblySemVer; milestone = string.Concat("v", version); fullSemVersion = assertedVersions.FullSemVer; - } if (string.IsNullOrWhiteSpace(version)) { @@ -61,4 +58,4 @@ public static BuildVersion Calculate(Context context) return new BuildVersion(version, semVersion, informationalVersion, assemblySemVer, milestone, fullSemVersion); } -} \ No newline at end of file +} From 9734d003c4c4aa4f32ef87ca53b15811e7bf6558 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sat, 27 Jun 2020 10:12:27 +0100 Subject: [PATCH 02/14] (GH-82) Add .editorconfig file Which will use the correct line endings, based on which system is being used. --- .editorconfig | 24 ++++++++++++++++++- .gitattributes | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .gitattributes diff --git a/.editorconfig b/.editorconfig index a709d6b..2b0b2cb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,14 +1,36 @@ ; This file is for unifying the coding style for different editors and IDEs. ; More information at http://EditorConfig.org + root = true [*] -end_of_line = CRLF +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{sln,csproj}] +end_of_line = crlf + +[*.md] +trim_trailing_whitespace = false [*.ps1] indent_style = space indent_size = 2 +charset = utf-8-bom +end_of_line = crlf + +[*.{yml,yaml}] +indent_size = 2 +indent_style = space + +# Files that need to be crlf eol to work +[tasks.json] +end_of_line = crlf [*.cs] indent_style = space diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..a1e1e97 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain \ No newline at end of file From 8c26e9bf7e351608e264f9e92bc992377a72c17d Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sat, 27 Jun 2020 10:13:16 +0100 Subject: [PATCH 03/14] (build) Ignore mac specific files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a46f1c5..f46ccd7 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,5 @@ packages # Windows Thumbs.db + +.DS_Store From b9e980047ed8807285e544d1707baee04f06e7a9 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sat, 27 Jun 2020 10:17:37 +0100 Subject: [PATCH 04/14] (GH-83) Install NuGet.Commandline using ToolInstaller Similar to how GitVersion is installed. --- build.ps1 | 12 ------------ build/Lifetime.cs | 3 ++- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/build.ps1 b/build.ps1 index 10cfd49..d0c8a5a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,6 @@ Param( $DotNetVersion = "3.1.301"; $DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1"; -$NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" # Make sure tools folder exists $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent @@ -77,17 +76,6 @@ if($FoundDotNetCliVersion -ne $DotNetVersion) { $env:DOTNET_CLI_TELEMETRY_OPTOUT=1 } -########################################################################### -# INSTALL NUGET -########################################################################### - -# Make sure nuget.exe exists. -$NugetPath = Join-Path $ToolPath "nuget.exe" -if (!(Test-Path $NugetPath)) { - Write-Host "Downloading NuGet.exe..." - (New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath); -} - ########################################################################### # RUN BUILD SCRIPT ########################################################################### diff --git a/build/Lifetime.cs b/build/Lifetime.cs index bd133ce..29b2448 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -39,6 +39,7 @@ public override void Setup(Context context) // Install tools context.Information("Installing tools..."); + ToolInstaller.Install(context, "NuGet.CommandLine", "5.6.0"); // Install Global .Net Tools context.Information("Installing .Net Global Tools..."); @@ -79,4 +80,4 @@ private static string GetEnvironmentValueOrArgument(Context context, string envi } return arg; } -} \ No newline at end of file +} From dfbc4f0c3d9af6331eb75fb2a9f07a7acfe2f80d Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sat, 27 Jun 2020 10:22:05 +0100 Subject: [PATCH 05/14] (GH-84) Create build.config file To pin to a specific version of dotnet --- build.config | 2 ++ build.ps1 | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 build.config diff --git a/build.config b/build.config new file mode 100644 index 0000000..da9a3c7 --- /dev/null +++ b/build.config @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +DOTNET_VERSION=3.1.301 diff --git a/build.ps1 b/build.ps1 index d0c8a5a..0df998f 100644 --- a/build.ps1 +++ b/build.ps1 @@ -31,7 +31,19 @@ Param( [string[]]$ScriptArgs ) -$DotNetVersion = "3.1.301"; +[string] $DotNetVersion= '' +foreach($line in Get-Content (Join-Path $PSScriptRoot 'build.config')) +{ + if ($line -like 'DOTNET_VERSION=*') { + $DotNetVersion =$line.SubString(15) + } +} + +if ([string]::IsNullOrEmpty($DotNetVersion)) { + 'Failed to parse .NET Core SDK Version' + exit 1 +} + $DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1"; # Make sure tools folder exists From 4ed2a4ca2a07402634e86c988e0f88915124e3c3 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sat, 27 Jun 2020 10:43:17 +0100 Subject: [PATCH 06/14] (GH-80) Add build.sh for building on posix In order to get this to compile, I had to remove the 461 target. Could be that there is something else that can be done here. --- build.sh | 50 +++++++++++++++++++ build/Build.csproj | 4 +- .../Cake.Frosting.Example.csproj | 7 ++- .../Cake.Frosting.Tests.csproj | 15 +++--- src/Cake.Frosting/Cake.Frosting.csproj | 5 +- template/Build.csproj | 4 +- 6 files changed, 70 insertions(+), 15 deletions(-) create mode 100755 build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..e17152e --- /dev/null +++ b/build.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Define varibles +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +source $SCRIPT_DIR/build.config +TOOLS_DIR=$SCRIPT_DIR/tools + +if [ "$DOTNET_VERSION" = "" ]; then + echo "An error occured while parsing .NET Core SDK version." + exit 1 +fi + +# Make sure the tools folder exist. +if [ ! -d "$TOOLS_DIR" ]; then + mkdir "$TOOLS_DIR" +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 + echo "Installing .NET CLI..." + 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 + bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version $DOTNET_VERSION --install-dir .dotnet --no-path + export PATH="$SCRIPT_DIR/.dotnet":$PATH + export DOTNET_ROOT="$SCRIPT_DIR/.dotnet" +fi + +########################################################################### +# RUN BUILD SCRIPT +########################################################################### + +echo "Running build script.." +pushd . +echo "Changing to build folder..." +cd build +echo "dotnet run..." +dotnet run --project Build.csproj -- "$@" +echo "going back to previous folder..." +popd diff --git a/build/Build.csproj b/build/Build.csproj index 72a73c5..52021c5 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -2,11 +2,11 @@ Exe - net461 + netcoreapp3.0 - + diff --git a/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj b/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj index a69c2a7..17ad2bd 100644 --- a/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj +++ b/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj @@ -8,7 +8,7 @@ git https://github.com/cake-build/frosting 0.1.0 - net461;netcoreapp2.0 + netcoreapp3.0 Cake.Frosting.Example Exe Cake.Frosting.Example @@ -20,4 +20,7 @@ - \ No newline at end of file + + + + diff --git a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj index 5b9fabe..0b14f14 100644 --- a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj +++ b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj @@ -8,11 +8,11 @@ https://github.com/cake-build/frosting/blob/develop/LICENSE git https://github.com/cake-build/frosting - net461;netcoreapp2.0 + netcoreapp3.0 7 - + $(DefineConstants);NETCORE portable @@ -22,15 +22,16 @@ - - - + + + - + + - \ No newline at end of file + diff --git a/src/Cake.Frosting/Cake.Frosting.csproj b/src/Cake.Frosting/Cake.Frosting.csproj index 9dc3d37..206c937 100644 --- a/src/Cake.Frosting/Cake.Frosting.csproj +++ b/src/Cake.Frosting/Cake.Frosting.csproj @@ -10,7 +10,7 @@ git https://github.com/cake-build/frosting 0.1.0 - netstandard2.0;net461 + netstandard2.0 true Cake.Frosting false @@ -29,6 +29,7 @@ + @@ -38,4 +39,4 @@ true - \ No newline at end of file + diff --git a/template/Build.csproj b/template/Build.csproj index f78a2ec..8d5d411 100644 --- a/template/Build.csproj +++ b/template/Build.csproj @@ -2,11 +2,11 @@ Exe - netcoreapp2.0 + netcoreapp3.0 - \ No newline at end of file + From 9ac3550424f1bf7101aca70e4209779f7be2b98e Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sat, 27 Jun 2020 10:45:43 +0100 Subject: [PATCH 07/14] (build) Switch to direct run of build Rather than restoring, publishing, then running. --- build.ps1 | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/build.ps1 b/build.ps1 index 0df998f..6cb84e3 100644 --- a/build.ps1 +++ b/build.ps1 @@ -103,16 +103,8 @@ $Arguments = @{ try { Push-Location Set-Location build - Write-Host "Restoring packages..." - Invoke-Expression "dotnet restore" - if($LASTEXITCODE -eq 0) { - Write-Output "Compiling build..." - Invoke-Expression "dotnet publish -c Debug /v:q /nologo" - if($LASTEXITCODE -eq 0) { - Write-Output "Running build..." - Invoke-Expression "bin/Debug/net461/publish/Build.exe $Arguments" - } - } + Write-Output "Running build..." + Invoke-Expression "dotnet run --project Build.csproj -- $Arguments" } finally { Pop-Location From 36b1938d3a210cc9419bc61a8c7f572c7d3e044d Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sat, 27 Jun 2020 13:32:15 +0100 Subject: [PATCH 08/14] (GH-80) Trying to add back in net461 Based on some suggestions from @devlead, tried to run unit tests for each project, as well as providing a FrameworkOverride path to use Mono. Neither of these seem to work, but wanted to put the work up for folks to take a look at. --- build.sh | 3 --- build/Lifetime.cs | 19 +++++++++++++++++++ build/Tasks/UnitTests.cs | 18 ++++++++++++------ .../Cake.Frosting.Example.csproj | 2 +- .../Cake.Frosting.Tests.csproj | 12 +++++++++--- src/Cake.Frosting/Cake.Frosting.csproj | 2 +- 6 files changed, 42 insertions(+), 14 deletions(-) diff --git a/build.sh b/build.sh index e17152e..d3dc0f3 100755 --- a/build.sh +++ b/build.sh @@ -42,9 +42,6 @@ fi echo "Running build script.." pushd . -echo "Changing to build folder..." cd build -echo "dotnet run..." dotnet run --project Build.csproj -- "$@" -echo "going back to previous folder..." popd diff --git a/build/Lifetime.cs b/build/Lifetime.cs index 29b2448..efe85c7 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Cake.Common; using Cake.Common.Diagnostics; using Cake.Common.Build; @@ -58,6 +59,24 @@ public override void Setup(Context context) .WithProperty("AssemblyVersion", context.Version.Version) .WithProperty("FileVersion", context.Version.Version); + if(!context.IsRunningOnWindows()) + { + var frameworkPathOverride = context.Environment.Runtime.IsCoreClr + ? new []{ + new DirectoryPath("/Library/Frameworks/Mono.framework/Versions/Current/lib/mono"), + new DirectoryPath("/usr/lib/mono"), + new DirectoryPath("/usr/local/lib/mono") + } + .Select(directory =>directory.Combine("4.5")) + .FirstOrDefault(directory => context.FileSystem.Exist(directory)) + ?.FullPath + "/" + : new FilePath(typeof(object).Assembly.Location).GetDirectory().FullPath + "/"; + + // Use FrameworkPathOverride when not running on Windows. + context.Information("Build will use FrameworkPathOverride={0} since not building on Windows.", frameworkPathOverride); + context.MSBuildSettings.WithProperty("FrameworkPathOverride", frameworkPathOverride); + } + context.Information("Version: {0}", context.Version); context.Information("Sem version: {0}", context.Version.SemVersion); context.Information("Configuration: {0}", context.BuildConfiguration); diff --git a/build/Tasks/UnitTests.cs b/build/Tasks/UnitTests.cs index 84e2463..8f4602d 100644 --- a/build/Tasks/UnitTests.cs +++ b/build/Tasks/UnitTests.cs @@ -7,10 +7,16 @@ public class UnitTests : FrostingTask { public override void Run(Context context) { - var project = "./src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj"; - context.DotNetCoreTest(project, new DotNetCoreTestSettings { - Configuration = context.BuildConfiguration, - NoBuild = true - }); + foreach(var framework in new[] { "netcoreapp2.0", "netcoreapp3.0", "net461" }) + { + var project = "./src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj"; + + context.DotNetCoreTest(project, new DotNetCoreTestSettings { + Framework = framework, + Configuration = context.BuildConfiguration, + NoBuild = true, + NoRestore = true + }); + } } -} \ No newline at end of file +} diff --git a/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj b/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj index 17ad2bd..ddcbd73 100644 --- a/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj +++ b/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj @@ -8,7 +8,7 @@ git https://github.com/cake-build/frosting 0.1.0 - netcoreapp3.0 + net461;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0 Cake.Frosting.Example Exe Cake.Frosting.Example diff --git a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj index 0b14f14..66a108d 100644 --- a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj +++ b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj @@ -8,7 +8,7 @@ https://github.com/cake-build/frosting/blob/develop/LICENSE git https://github.com/cake-build/frosting - netcoreapp3.0 + net461;netcoreapp2.0;netcoreapp3.0 7 @@ -22,12 +22,18 @@ - - + + + + + + + + diff --git a/src/Cake.Frosting/Cake.Frosting.csproj b/src/Cake.Frosting/Cake.Frosting.csproj index 206c937..52f3315 100644 --- a/src/Cake.Frosting/Cake.Frosting.csproj +++ b/src/Cake.Frosting/Cake.Frosting.csproj @@ -10,7 +10,7 @@ git https://github.com/cake-build/frosting 0.1.0 - netstandard2.0 + net461;netstandard2.0 true Cake.Frosting false From 673ce64267cc24a97f1d3a348b2e3d81fae25b1f Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Tue, 30 Jun 2020 10:56:50 +0200 Subject: [PATCH 09/14] (GH-93) Set project directory as working directory * fixes #93 --- appveyor.yml | 8 +++++++- build.ps1 | 12 ++---------- build.sh | 11 +---------- build/Build.csproj | 3 +++ build/Build.sln | 23 +++++++++++++---------- 5 files changed, 26 insertions(+), 31 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 017a942..234971c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,10 @@ # Image used -image: Visual Studio 2019 +image: + - Visual Studio 2019 + - Ubuntu + +environment: + APPVEYOR_YML_DISABLE_PS_LINUX: true # Build script init: @@ -8,6 +13,7 @@ init: # Build script build_script: - ps: .\build.ps1 -Target "AppVeyor" + - sh: ./build.sh --target="AppVeyor" # Tests test: off diff --git a/build.ps1 b/build.ps1 index 6cb84e3..2ed25bd 100644 --- a/build.ps1 +++ b/build.ps1 @@ -100,13 +100,5 @@ $Arguments = @{ dryrun=$WhatIf; }.GetEnumerator() | ForEach-Object { "--{0}=`"{1}`"" -f $_.key, $_.value }; -try { - Push-Location - Set-Location build - Write-Output "Running build..." - Invoke-Expression "dotnet run --project Build.csproj -- $Arguments" -} -finally { - Pop-Location - exit $LASTEXITCODE; -} +dotnet run --project build/Build.csproj -- $Arguments +exit $LASTEXITCODE; \ No newline at end of file diff --git a/build.sh b/build.sh index d3dc0f3..bd9974b 100755 --- a/build.sh +++ b/build.sh @@ -2,18 +2,12 @@ # Define varibles SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) source $SCRIPT_DIR/build.config -TOOLS_DIR=$SCRIPT_DIR/tools if [ "$DOTNET_VERSION" = "" ]; then echo "An error occured while parsing .NET Core SDK version." exit 1 fi -# Make sure the tools folder exist. -if [ ! -d "$TOOLS_DIR" ]; then - mkdir "$TOOLS_DIR" -fi - ########################################################################### # INSTALL .NET CORE CLI ########################################################################### @@ -41,7 +35,4 @@ fi ########################################################################### echo "Running build script.." -pushd . -cd build -dotnet run --project Build.csproj -- "$@" -popd +dotnet run --project ./build/Build.csproj -- "$@" diff --git a/build/Build.csproj b/build/Build.csproj index 52021c5..a03fc30 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -3,6 +3,9 @@ Exe netcoreapp3.0 + + + $(MSBuildProjectDirectory) diff --git a/build/Build.sln b/build/Build.sln index fd552b9..9837460 100644 --- a/build/Build.sln +++ b/build/Build.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26127.3 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30204.135 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Build", "Build.csproj", "{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}" EndProject @@ -17,18 +17,21 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x64.ActiveCfg = Debug|x64 - {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x64.Build.0 = Debug|x64 - {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x86.ActiveCfg = Debug|x86 - {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x86.Build.0 = Debug|x86 + {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x64.ActiveCfg = Debug|Any CPU + {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x64.Build.0 = Debug|Any CPU + {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x86.ActiveCfg = Debug|Any CPU + {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x86.Build.0 = Debug|Any CPU {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|Any CPU.ActiveCfg = Release|Any CPU {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|Any CPU.Build.0 = Release|Any CPU - {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x64.ActiveCfg = Release|x64 - {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x64.Build.0 = Release|x64 - {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x86.ActiveCfg = Release|x86 - {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x86.Build.0 = Release|x86 + {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x64.ActiveCfg = Release|Any CPU + {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x64.Build.0 = Release|Any CPU + {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x86.ActiveCfg = Release|Any CPU + {0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {062A93C5-869B-4AE7-8B68-B69E878C1507} + EndGlobalSection EndGlobal From a91743c948c18d4c4b4b37c0e6c194f12be6d91a Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Tue, 30 Jun 2020 10:58:19 +0200 Subject: [PATCH 10/14] (GH-94) Don't require NuGet.exe to download NuGet.exe * fixes #94 --- build/Lifetime.cs | 8 ++-- build/Utilities/ToolInstaller.cs | 70 +++++++++++++++++++++++++++++++- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/build/Lifetime.cs b/build/Lifetime.cs index efe85c7..f2383ed 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -40,13 +40,13 @@ public override void Setup(Context context) // Install tools context.Information("Installing tools..."); - ToolInstaller.Install(context, "NuGet.CommandLine", "5.6.0"); + context.InstallNuGetExe("5.6.0"); // Install Global .Net Tools context.Information("Installing .Net Global Tools..."); - ToolInstaller.DotNetCoreToolInstall(context, "GitReleaseManager.Tool", "0.11.0", "dotnet-gitreleasemanager"); - ToolInstaller.DotNetCoreToolInstall(context, "SignClient", "1.2.109", "SignClient"); - ToolInstaller.DotNetCoreToolInstall(context, "GitVersion.Tool", "5.1.2", "dotnet-gitversion"); + context.DotNetCoreToolInstall("GitReleaseManager.Tool", "0.11.0", "dotnet-gitreleasemanager"); + context.DotNetCoreToolInstall("SignClient", "1.2.109", "SignClient"); + context.DotNetCoreToolInstall("GitVersion.Tool", "5.1.2", "dotnet-gitversion"); // Calculate semantic version. context.Version = BuildVersion.Calculate(context); diff --git a/build/Utilities/ToolInstaller.cs b/build/Utilities/ToolInstaller.cs index 12c1dac..b5e587a 100644 --- a/build/Utilities/ToolInstaller.cs +++ b/build/Utilities/ToolInstaller.cs @@ -1,4 +1,8 @@ +using System; +using System.IO; +using Cake.Common.Diagnostics; using Cake.Common.IO; +using Cake.Common.Net; using Cake.Common.Tools.DotNetCore; using Cake.Common.Tools.DotNetCore.Tool; using Cake.Common.Tools.NuGet; @@ -10,7 +14,71 @@ public static class ToolInstaller { private static DirectoryPath ToolsPath { get; } = "./tools"; - public static void Install(ICakeContext context, string package, string version) + public static void InstallNuGetExe(this ICakeContext context, string version) + { + + var toolsPath = context.MakeAbsolute(ToolsPath); + + context.EnsureDirectoryExists(toolsPath); + + var nugetExePath = toolsPath.CombineWithFilePath("nuget.exe"); + + if (context.FileExists(nugetExePath)) + { + if (TryValidateVersion(version, nugetExePath, out var existingVersion)) + { + context.Tools.RegisterFile(nugetExePath); + return; + } + + context.Information( + "Found version {0} expected {1}, deleting {2}...", + existingVersion, + version, + toolsPath + ); + + context.DeleteFile(nugetExePath); + } + + var address = $"https://dist.nuget.org/win-x86-commandline/v{Uri.EscapeDataString(version)}/nuget.exe"; + context.Information("Downloading NuGet exe from {0} to {1}...", address, nugetExePath); + context.DownloadFile( + address, + nugetExePath + ); + + if (!context.FileExists(nugetExePath)) + { + throw new Exception("Failed to install NuGet exe."); + } + + + if (!TryValidateVersion(version, nugetExePath, out var downloadedFileVersion)) + { + throw new Exception($"Expected version {version} got {downloadedFileVersion}"); + } + + context.Tools.RegisterFile(nugetExePath); + context.Information("NuGet exe downloaded and registered successfully."); + } + + private static bool TryValidateVersion(string expectedVersion, FilePath nugetExePath, out string foundVersion) + { + try + { + var fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(nugetExePath.FullPath); + foundVersion = FormattableString.Invariant($"{fileVersion.FileMajorPart}.{fileVersion.FileMinorPart}.{fileVersion.FileBuildPart}"); + return foundVersion == expectedVersion; + } + catch(Exception ex) + { + foundVersion = ex.Message; + return false; + } + } + + public static void Install(this ICakeContext context, string package, string version) { context.NuGetInstall(package, new NuGetInstallSettings { Version = version, From e4fce50233b5c4fb239ddc3cf4a3322c760ae661 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Tue, 30 Jun 2020 11:05:31 +0200 Subject: [PATCH 11/14] (build) No autocrlf on AppVeyor Ubuntu --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 234971c..7f8379a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,7 +8,7 @@ environment: # Build script init: - - git config --global core.autocrlf true + - ps: git config --global core.autocrlf true # Build script build_script: From cdd4c437365441b3441454d8d0fac0923cb4ecab Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Tue, 30 Jun 2020 11:16:15 +0200 Subject: [PATCH 12/14] (GH-88) Add GitHub Actions build * fixes #88 --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 31807f0..bea4efb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,3 +23,7 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: '3.1.301' + + - name: Run Frosting Build + run: | + dotnet run --project ./build/Build.csproj From d28f433bca7895a3396d82a956944ee18c1c9af4 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Tue, 30 Jun 2020 11:41:35 +0200 Subject: [PATCH 13/14] (GH-95) Update test references to from version 15.x to 16.x * fixes #95 --- .github/workflows/build.yml | 2 ++ build/Tasks/UnitTests.cs | 2 +- .../Cake.Frosting.Tests.csproj | 25 ++++++++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bea4efb..6a672a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,5 +25,7 @@ jobs: dotnet-version: '3.1.301' - name: Run Frosting Build + env: + DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX: 2 run: | dotnet run --project ./build/Build.csproj diff --git a/build/Tasks/UnitTests.cs b/build/Tasks/UnitTests.cs index 8f4602d..3d49647 100644 --- a/build/Tasks/UnitTests.cs +++ b/build/Tasks/UnitTests.cs @@ -7,7 +7,7 @@ public class UnitTests : FrostingTask { public override void Run(Context context) { - foreach(var framework in new[] { "netcoreapp2.0", "netcoreapp3.0", "net461" }) + foreach(var framework in new[] { "netcoreapp2.1", "netcoreapp3.0", "net461" }) { var project = "./src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj"; diff --git a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj index 66a108d..4351435 100644 --- a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj +++ b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj @@ -1,4 +1,4 @@ - + Copyright (c) .NET Foundation and contributors @@ -8,11 +8,11 @@ https://github.com/cake-build/frosting/blob/develop/LICENSE git https://github.com/cake-build/frosting - net461;netcoreapp2.0;netcoreapp3.0 + net461;netcoreapp2.1;netcoreapp3.0 7 - + $(DefineConstants);NETCORE portable @@ -22,18 +22,25 @@ - + + - - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + - + + + + From 4c4fc1e0ba6bd650bea8427a1ecbe6740f7a3353 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Tue, 30 Jun 2020 12:46:51 +0200 Subject: [PATCH 14/14] (GH-96) Harmonize build.ps1 arguments with build.sh / .NET CLI * fixes #96 --- appveyor.yml | 4 ++-- build.ps1 | 52 +++++++++------------------------------------------- 2 files changed, 11 insertions(+), 45 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 7f8379a..f9c829b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,7 +12,7 @@ init: # Build script build_script: - - ps: .\build.ps1 -Target "AppVeyor" + - ps: .\build.ps1 --target="AppVeyor" - sh: ./build.sh --target="AppVeyor" # Tests @@ -30,4 +30,4 @@ branches: # Build cache cache: -- tools -> build.ps1, global.json \ No newline at end of file +- tools -> build.ps1, global.json, build.sh, build.config \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 2ed25bd..8f9b465 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,35 +1,8 @@ -<# -.SYNOPSIS -This is a Powershell script to bootstrap a Cake build. -.DESCRIPTION -This Powershell script will download NuGet if missing, restore NuGet tools (including Cake) -and execute your Cake build script with the parameters you provide. -.PARAMETER Target -The build script target to run. -.PARAMETER Configuration -The build configuration to use. -.PARAMETER Verbosity -Specifies the amount of information to be displayed. -.PARAMETER WhatIf -Performs a dry run of the build script. -No tasks will be executed. -.PARAMETER ScriptArgs -Remaining arguments are added here. -.LINK -https://cakebuild.net -#> - -[CmdletBinding()] -Param( - [string]$Target = "Default", - [ValidateSet("Release", "Debug")] - [string]$Configuration = "Release", - [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] - [string]$Verbosity = "Verbose", - [switch]$WhatIf, - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] - [string[]]$ScriptArgs -) +#!/usr/bin/env pwsh +$DotNetInstallerUri = 'https://dot.net/v1/dotnet-install.ps1'; +$DotNetUnixInstallerUri = 'https://dot.net/v1/dotnet-install.sh' +$DotNetChannel = 'LTS' +$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent [string] $DotNetVersion= '' foreach($line in Get-Content (Join-Path $PSScriptRoot 'build.config')) @@ -39,9 +12,10 @@ foreach($line in Get-Content (Join-Path $PSScriptRoot 'build.config')) } } + if ([string]::IsNullOrEmpty($DotNetVersion)) { - 'Failed to parse .NET Core SDK Version' - exit 1 + 'Failed to parse .NET Core SDK Version' + exit 1 } $DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1"; @@ -92,13 +66,5 @@ if($FoundDotNetCliVersion -ne $DotNetVersion) { # RUN BUILD SCRIPT ########################################################################### -# Build the argument list. -$Arguments = @{ - target=$Target; - configuration=$Configuration; - verbosity=$Verbosity; - dryrun=$WhatIf; -}.GetEnumerator() | ForEach-Object { "--{0}=`"{1}`"" -f $_.key, $_.value }; - -dotnet run --project build/Build.csproj -- $Arguments +dotnet run --project build/Build.csproj -- $args exit $LASTEXITCODE; \ No newline at end of file