From 80cbe36c509984042e25bc401b1b7210b8ddd10f Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Fri, 26 Jun 2020 16:09:18 +0200 Subject: [PATCH 01/48] (GH-73) Update to .NET Core SDK 3.1.301 * fixes #73 --- build.ps1 | 2 +- build/global.json | 2 +- global.json | 2 +- template/build.ps1 | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build.ps1 b/build.ps1 index f691b99..10cfd49 100644 --- a/build.ps1 +++ b/build.ps1 @@ -31,7 +31,7 @@ Param( [string[]]$ScriptArgs ) -$DotNetVersion = "2.1.807"; +$DotNetVersion = "3.1.301"; $DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1"; $NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" diff --git a/build/global.json b/build/global.json index 3789e80..acbfc84 100644 --- a/build/global.json +++ b/build/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "2.1.807", + "version": "3.1.301", "rollForward": "latestMajor" } } diff --git a/global.json b/global.json index 3c913e7..6e90c94 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "2.1.807", + "version": "3.1.301", "rollForward": "latestMajor" } } diff --git a/template/build.ps1 b/template/build.ps1 index bc8fea0..8bd24ea 100644 --- a/template/build.ps1 +++ b/template/build.ps1 @@ -1,6 +1,6 @@ <# .SYNOPSIS -This is a Powershell script to bootstrap a Cake.Frosting build. +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. @@ -16,7 +16,7 @@ No tasks will be executed. .PARAMETER ScriptArgs Remaining arguments are added here. .LINK -https://github.com/cake-build/frosting +https://cakebuild.net #> [CmdletBinding()] @@ -31,7 +31,7 @@ Param( [string[]]$ScriptArgs ) -$DotNetVersion = "1.0.4"; +$DotNetVersion = "3.1.301"; $DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1"; $NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" @@ -82,7 +82,7 @@ if($FoundDotNetCliVersion -ne $DotNetVersion) { ########################################################################### # Make sure nuget.exe exists. -$NugetPath = Join-Path $ToolPath "nuget.exe" +$NugetPath = Join-Path $ToolPath "nuget.exe" if (!(Test-Path $NugetPath)) { Write-Host "Downloading NuGet.exe..." (New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath); @@ -110,7 +110,7 @@ try { Invoke-Expression "dotnet publish -c Debug /v:q /nologo" if($LASTEXITCODE -eq 0) { Write-Output "Running build..." - Invoke-Expression "dotnet bin/Debug/netcoreapp1.1/publish/Build.dll $Arguments" + Invoke-Expression "bin/Debug/net461/publish/Build.exe $Arguments" } } } From b028dc53a4e6bd3fdb4cac052dffad62157cb293 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Fri, 26 Jun 2020 16:16:31 +0200 Subject: [PATCH 02/48] Fix cache --- appveyor.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 530c9a8..017a942 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,5 +24,4 @@ branches: # Build cache cache: -- build.ps1 -- global.json \ No newline at end of file +- tools -> build.ps1, global.json \ No newline at end of file From 091597e164df6502d1e6b13658af2d2b589a23cc Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Fri, 26 Jun 2020 18:48:55 +0200 Subject: [PATCH 03/48] (GH-74) Update to Cake 0.38.4 --- src/Cake.Frosting/Cake.Frosting.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cake.Frosting/Cake.Frosting.csproj b/src/Cake.Frosting/Cake.Frosting.csproj index af499f5..df06f32 100644 --- a/src/Cake.Frosting/Cake.Frosting.csproj +++ b/src/Cake.Frosting/Cake.Frosting.csproj @@ -23,8 +23,8 @@ portable - - + + From 0b4d06df2764842e9df62a608b31cece312d9223 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sun, 28 Jun 2020 08:22:48 +0100 Subject: [PATCH 04/48] (GH-86) Change to pushing to Azure Artifacts This is in line with what is done for the main Cake project. --- build/Context.cs | 10 +++-- build/Lifetime.cs | 6 ++- build/Tasks/AppVeyor.cs | 6 +-- build/Tasks/PublishAzureArtifacts.cs | 62 ++++++++++++++++++++++++++++ build/Tasks/PublishMyGet.cs | 45 -------------------- 5 files changed, 75 insertions(+), 54 deletions(-) create mode 100644 build/Tasks/PublishAzureArtifacts.cs delete mode 100644 build/Tasks/PublishMyGet.cs diff --git a/build/Context.cs b/build/Context.cs index a587c33..34766e7 100644 --- a/build/Context.cs +++ b/build/Context.cs @@ -13,9 +13,11 @@ public class Context : FrostingContext public DirectoryPath Artifacts { get; set; } - public string MyGetSource { get; set; } - public string MyGetApiKey { get; set; } - + public string AzureArtifactsSourceUrl { get; set; } + public string AzureArtifactsSourceName { get; set; } + public string AzureArtifactsPersonalAccessToken { get; set; } + public string AzureArtifactsSourceUserName { get; set; } + public bool IsLocalBuild { get; set; } public bool IsPullRequest { get; set; } public bool IsOriginalRepo { get; set; } @@ -31,4 +33,4 @@ public Context(ICakeContext context) : base(context) { } -} \ No newline at end of file +} diff --git a/build/Lifetime.cs b/build/Lifetime.cs index 6b64416..2e58e8e 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -15,8 +15,10 @@ public override void Setup(Context context) context.Target = context.Argument("target", "Default"); context.BuildConfiguration = context.Argument("configuration", "Release"); context.ForcePublish = context.Argument("forcepublish", false); - context.MyGetSource = GetEnvironmentValueOrArgument(context, "FROSTING_MYGET_SOURCE", "mygetsource"); - context.MyGetApiKey = GetEnvironmentValueOrArgument(context, "FROSTING_MYGET_API_KEY", "mygetapikey"); + context.AzureArtifactsSourceUrl = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_URL", "azureartifactssourceurl"); + context.AzureArtifactsPersonalAccessToken = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN", "mygetapikey"); + context.AzureArtifactsSourceName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_NAME", "azureartifactssourcename"); + context.AzureArtifactsSourceUserName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_USER_NAME", "azureartifactssourceusername"); // Directories context.Artifacts = new DirectoryPath("./artifacts"); diff --git a/build/Tasks/AppVeyor.cs b/build/Tasks/AppVeyor.cs index 7020728..bf11a86 100644 --- a/build/Tasks/AppVeyor.cs +++ b/build/Tasks/AppVeyor.cs @@ -1,11 +1,11 @@ using Cake.Frosting; [Dependency(typeof(AppVeyorArtifacts))] -[Dependency(typeof(PublishMyGet))] +[Dependency(typeof(PublishAzureArtifacts))] public class AppVeyor : FrostingTask { public override bool ShouldRun(Context context) { return context.AppVeyor; - } -} \ No newline at end of file + } +} diff --git a/build/Tasks/PublishAzureArtifacts.cs b/build/Tasks/PublishAzureArtifacts.cs new file mode 100644 index 0000000..731c89a --- /dev/null +++ b/build/Tasks/PublishAzureArtifacts.cs @@ -0,0 +1,62 @@ +using Cake.Common.Tools.NuGet; +using Cake.Common.Tools.NuGet.Push; +using Cake.Common.Tools.NuGet.Sources; +using Cake.Core; +using Cake.Core.IO; +using Cake.Frosting; + +[Dependency(typeof(Package))] +[Dependency(typeof(AppVeyorArtifacts))] +public class PublishAzureArtifacts : FrostingTask +{ + public override bool ShouldRun(Context context) + { + return !context.IsLocalBuild && !context.IsPullRequest && context.IsOriginalRepo + && (context.IsTagged || !context.IsMasterBranch); + } + + public override void Run(Context context) + { + if(context.AzureArtifactsSourceUrl == null) + { + throw new CakeException("Azure Artifacts source URL was not provided."); + } + if(context.AzureArtifactsSourceName == null) + { + throw new CakeException("Azure Artifacts source name was not provided."); + } + if(context.AzureArtifactsPersonalAccessToken == null) + { + throw new CakeException("Azure Artifacts Personal Access Token was not provided."); + } + if(context.AzureArtifactsSourceUserName == null) + { + throw new CakeException("Azure Artifacts username was not provided."); + } + + // Get the file paths. + var root = new DirectoryPath("./src/Cake.Frosting"); + var files = new[] { + $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.symbols.nupkg" + }; + + if(!context.NuGetHasSource(context.AzureArtifactsSourceName)) + { + context.NuGetAddSource(context.AzureArtifactsSourceName, context.AzureArtifactsSourceUrl, new NuGetSourcesSettings{ + UserName = context.AzureArtifactsSourceUserName, + Password = context.AzureArtifactsPersonalAccessToken + }); + } + + // Push files + foreach(var file in files) + { + context.NuGetPush(file, new NuGetPushSettings { + Source = context.AzureArtifactsSourceName, + ApiKey = "az" + }); + } + } +} diff --git a/build/Tasks/PublishMyGet.cs b/build/Tasks/PublishMyGet.cs deleted file mode 100644 index 7b382d7..0000000 --- a/build/Tasks/PublishMyGet.cs +++ /dev/null @@ -1,45 +0,0 @@ -using Cake.Common.Tools.NuGet; -using Cake.Common.Tools.NuGet.Push; -using Cake.Core; -using Cake.Core.IO; -using Cake.Frosting; - -[Dependency(typeof(Package))] -[Dependency(typeof(AppVeyorArtifacts))] -public class PublishMyGet : FrostingTask -{ - public override bool ShouldRun(Context context) - { - return !context.IsLocalBuild && !context.IsPullRequest && context.IsOriginalRepo - && (context.IsTagged || !context.IsMasterBranch); - } - - public override void Run(Context context) - { - if(context.MyGetSource == null) - { - throw new CakeException("MyGet source was not provided."); - } - if(context.MyGetApiKey == null) - { - throw new CakeException("MyGet API key was not provided."); - } - - // Get the file paths. - var root = new DirectoryPath("./src/Cake.Frosting"); - var files = new[] { - $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.symbols.nupkg" - }; - - // Push files - foreach(var file in files) - { - context.NuGetPush(file, new NuGetPushSettings { - Source = context.MyGetSource, - ApiKey = context.MyGetApiKey - }); - } - } -} \ No newline at end of file From 65c01ef3310d1b34b1e98550178c316e573eecd0 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sun, 28 Jun 2020 08:31:03 +0100 Subject: [PATCH 05/48] (GH-86) Remove symbols.nupkg file For now, removing this, as it causes a conflict when pushing. Fairly sure that the way that this works has changed. --- build/Tasks/PublishAzureArtifacts.cs | 123 +++++++++++++-------------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/build/Tasks/PublishAzureArtifacts.cs b/build/Tasks/PublishAzureArtifacts.cs index 731c89a..c91e348 100644 --- a/build/Tasks/PublishAzureArtifacts.cs +++ b/build/Tasks/PublishAzureArtifacts.cs @@ -1,62 +1,61 @@ -using Cake.Common.Tools.NuGet; -using Cake.Common.Tools.NuGet.Push; -using Cake.Common.Tools.NuGet.Sources; -using Cake.Core; -using Cake.Core.IO; -using Cake.Frosting; - -[Dependency(typeof(Package))] -[Dependency(typeof(AppVeyorArtifacts))] -public class PublishAzureArtifacts : FrostingTask -{ - public override bool ShouldRun(Context context) - { - return !context.IsLocalBuild && !context.IsPullRequest && context.IsOriginalRepo - && (context.IsTagged || !context.IsMasterBranch); - } - - public override void Run(Context context) - { - if(context.AzureArtifactsSourceUrl == null) - { - throw new CakeException("Azure Artifacts source URL was not provided."); - } - if(context.AzureArtifactsSourceName == null) - { - throw new CakeException("Azure Artifacts source name was not provided."); - } - if(context.AzureArtifactsPersonalAccessToken == null) - { - throw new CakeException("Azure Artifacts Personal Access Token was not provided."); - } - if(context.AzureArtifactsSourceUserName == null) - { - throw new CakeException("Azure Artifacts username was not provided."); - } - - // Get the file paths. - var root = new DirectoryPath("./src/Cake.Frosting"); - var files = new[] { - $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.symbols.nupkg" - }; - - if(!context.NuGetHasSource(context.AzureArtifactsSourceName)) - { - context.NuGetAddSource(context.AzureArtifactsSourceName, context.AzureArtifactsSourceUrl, new NuGetSourcesSettings{ - UserName = context.AzureArtifactsSourceUserName, - Password = context.AzureArtifactsPersonalAccessToken - }); - } - - // Push files - foreach(var file in files) - { - context.NuGetPush(file, new NuGetPushSettings { - Source = context.AzureArtifactsSourceName, - ApiKey = "az" - }); - } - } -} +using Cake.Common.Tools.NuGet; +using Cake.Common.Tools.NuGet.Push; +using Cake.Common.Tools.NuGet.Sources; +using Cake.Core; +using Cake.Core.IO; +using Cake.Frosting; + +[Dependency(typeof(Package))] +[Dependency(typeof(AppVeyorArtifacts))] +public class PublishAzureArtifacts : FrostingTask +{ + public override bool ShouldRun(Context context) + { + return !context.IsLocalBuild && !context.IsPullRequest && context.IsOriginalRepo + && (context.IsTagged || !context.IsMasterBranch); + } + + public override void Run(Context context) + { + if(context.AzureArtifactsSourceUrl == null) + { + throw new CakeException("Azure Artifacts source URL was not provided."); + } + if(context.AzureArtifactsSourceName == null) + { + throw new CakeException("Azure Artifacts source name was not provided."); + } + if(context.AzureArtifactsPersonalAccessToken == null) + { + throw new CakeException("Azure Artifacts Personal Access Token was not provided."); + } + if(context.AzureArtifactsSourceUserName == null) + { + throw new CakeException("Azure Artifacts username was not provided."); + } + + // Get the file paths. + var root = new DirectoryPath("./src/Cake.Frosting"); + var files = new[] { + $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg" + }; + + if(!context.NuGetHasSource(context.AzureArtifactsSourceName)) + { + context.NuGetAddSource(context.AzureArtifactsSourceName, context.AzureArtifactsSourceUrl, new NuGetSourcesSettings{ + UserName = context.AzureArtifactsSourceUserName, + Password = context.AzureArtifactsPersonalAccessToken + }); + } + + // Push files + foreach(var file in files) + { + context.NuGetPush(file, new NuGetPushSettings { + Source = context.AzureArtifactsSourceName, + ApiKey = "az" + }); + } + } +} From fbff144c83fac711cb460d7a0d5adb5155e5af9b Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sun, 28 Jun 2020 11:35:40 +0100 Subject: [PATCH 06/48] (GH-71) Add SourceLink to build This should generate a snupkg file, which will ultimately be pushed to NuGet.org. --- build/Tasks/AppVeyorArtifacts.cs | 66 +++++++++++----------- src/Cake.Frosting/Cake.Frosting.csproj | 76 ++++++++++++++------------ 2 files changed, 73 insertions(+), 69 deletions(-) diff --git a/build/Tasks/AppVeyorArtifacts.cs b/build/Tasks/AppVeyorArtifacts.cs index 57dcdac..91ee9b6 100644 --- a/build/Tasks/AppVeyorArtifacts.cs +++ b/build/Tasks/AppVeyorArtifacts.cs @@ -1,34 +1,34 @@ -using Cake.Common.Tools.NuGet; -using Cake.Common.Tools.NuGet.Push; -using Cake.Core; -using Cake.Core.IO; -using Cake.Frosting; - -[Dependency(typeof(Package))] -public class AppVeyorArtifacts : FrostingTask -{ - public override bool ShouldRun(Context context) - { - return context.AppVeyor; - } - - public override void Run(Context context) - { - // Get the file paths. - var root = new DirectoryPath("./src/Cake.Frosting"); - var files = new[] { - $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.symbols.nupkg" - }; - - - // Push files - foreach(var file in files) - { - context.BuildSystem.AppVeyor.UploadArtifact( - file - ); - } - } +using Cake.Common.Tools.NuGet; +using Cake.Common.Tools.NuGet.Push; +using Cake.Core; +using Cake.Core.IO; +using Cake.Frosting; + +[Dependency(typeof(Package))] +public class AppVeyorArtifacts : FrostingTask +{ + public override bool ShouldRun(Context context) + { + return context.AppVeyor; + } + + public override void Run(Context context) + { + // Get the file paths. + var root = new DirectoryPath("./src/Cake.Frosting"); + var files = new[] { + $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.snupkg" + }; + + + // Push files + foreach(var file in files) + { + context.BuildSystem.AppVeyor.UploadArtifact( + file + ); + } + } } \ No newline at end of file diff --git a/src/Cake.Frosting/Cake.Frosting.csproj b/src/Cake.Frosting/Cake.Frosting.csproj index df06f32..9dc3d37 100644 --- a/src/Cake.Frosting/Cake.Frosting.csproj +++ b/src/Cake.Frosting/Cake.Frosting.csproj @@ -1,37 +1,41 @@ - - - Cake.Frosting - The .NET Core host for Cake. - Copyright (c) .NET Foundation and contributors - Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström and contributors - Cake;Build;Build automation - cake-medium.png - MIT - git - https://github.com/cake-build/frosting - 0.1.0 - netstandard2.0;net461 - true - Cake.Frosting - false - false - false - 7.2 - - - $(DefineConstants);NETCORE - portable - - - - - - - - - - - - true - + + + Cake.Frosting + The .NET Core host for Cake. + Copyright (c) .NET Foundation and contributors + Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström and contributors + Cake;Build;Build automation + cake-medium.png + MIT + git + https://github.com/cake-build/frosting + 0.1.0 + netstandard2.0;net461 + true + Cake.Frosting + false + false + false + 7.2 + true + true + snupkg + + + $(DefineConstants);NETCORE + portable + + + + + + + + + + + + + true + \ No newline at end of file From 20d37c952cfb580d9fb125715f02759172333804 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sun, 28 Jun 2020 11:40:27 +0100 Subject: [PATCH 07/48] (GH-87) Remove symbols package generation This is now covered via the use of SourceLink, and the generated snupkg file. --- build/Tasks/Package.cs | 43 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/build/Tasks/Package.cs b/build/Tasks/Package.cs index 97ac716..b6e6eae 100644 --- a/build/Tasks/Package.cs +++ b/build/Tasks/Package.cs @@ -1,23 +1,22 @@ -using Cake.Common.Tools.DotNetCore; -using Cake.Common.Tools.DotNetCore.Pack; -using Cake.Core; -using Cake.Core.IO; -using Cake.Frosting; - -[Dependency(typeof(UnitTests))] -[Dependency(typeof(PackageTemplate))] -public class Package : FrostingTask -{ - public override void Run(Context context) - { - var path = new FilePath("./src/Cake.Frosting/Cake.Frosting.csproj"); - context.DotNetCorePack(path.FullPath, new DotNetCorePackSettings { - Configuration = context.BuildConfiguration, - MSBuildSettings = context.MSBuildSettings, - NoBuild = true, - NoRestore = true, - OutputDirectory = context.Artifacts, - ArgumentCustomization = args => args.Append("--include-symbols --include-source") - }); - } +using Cake.Common.Tools.DotNetCore; +using Cake.Common.Tools.DotNetCore.Pack; +using Cake.Core; +using Cake.Core.IO; +using Cake.Frosting; + +[Dependency(typeof(UnitTests))] +[Dependency(typeof(PackageTemplate))] +public class Package : FrostingTask +{ + public override void Run(Context context) + { + var path = new FilePath("./src/Cake.Frosting/Cake.Frosting.csproj"); + context.DotNetCorePack(path.FullPath, new DotNetCorePackSettings { + Configuration = context.BuildConfiguration, + MSBuildSettings = context.MSBuildSettings, + NoBuild = true, + NoRestore = true, + OutputDirectory = context.Artifacts + }); + } } \ No newline at end of file From a49e36419c1be4d828075385025b13de951e7aed Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sun, 28 Jun 2020 16:06:46 +0100 Subject: [PATCH 08/48] (GH-78) Add GRM for release notes creation In the same way that Cake uses GitReleaseManager to create its release notes, lets also use it here for Frosting release notes. With GRM now added into the mix, we can create another task for adding artifacts to the GitHub release once created. --- GitReleaseManager.yaml | 28 ++++++ build/Context.cs | 7 +- build/Lifetime.cs | 12 ++- build/Tasks/GitReleaseManager.cs | 25 ++++++ build/Tasks/PublishAzureArtifacts.cs | 122 +++++++++++++-------------- build/Utilities/BuildVersion.cs | 20 ++++- build/Utilities/ToolInstaller.cs | 65 +++++++++++++- 7 files changed, 211 insertions(+), 68 deletions(-) create mode 100644 GitReleaseManager.yaml create mode 100644 build/Tasks/GitReleaseManager.cs diff --git a/GitReleaseManager.yaml b/GitReleaseManager.yaml new file mode 100644 index 0000000..c85f3d7 --- /dev/null +++ b/GitReleaseManager.yaml @@ -0,0 +1,28 @@ +issue-labels-include: +- Breaking change +- Feature +- Bug +- Improvement +- Documentation +issue-labels-exclude: +- Build +issue-labels-alias: + - name: Documentation + header: Documentation + plural: Documentation +create: + include-sha-section: true + sha-section-heading: "SHA256 Hashes of the release artifacts" + sha-section-line-format: "- `{1}\t{0}`" +close: + use-issue-comments: true + issue-comment: |- + :tada: This issue has been resolved in version {milestone} :tada: + + The release is available on: + + - [GitHub Release](https://github.com/{owner}/{repository}/releases/tag/{milestone}) + - [NuGet Package](https://www.nuget.org/packages/Cake/{milestone}) + + Your **[GitReleaseManager](https://github.com/GitTools/GitReleaseManager)** bot :package::rocket: + diff --git a/build/Context.cs b/build/Context.cs index 34766e7..2dcb564 100644 --- a/build/Context.cs +++ b/build/Context.cs @@ -18,11 +18,16 @@ public class Context : FrostingContext public string AzureArtifactsPersonalAccessToken { get; set; } public string AzureArtifactsSourceUserName { get; set; } + public string GitHubToken { get; set; } + public bool IsLocalBuild { get; set; } public bool IsPullRequest { get; set; } public bool IsOriginalRepo { get; set; } + public string RepositoryOwner { get; set; } + public string RepositoryName { get; set; } public bool IsTagged { get; set; } - public bool IsMasterBranch { get; set; } + public bool IsPrimaryBranch { get; set; } + public string PrimaryBranchName { get; set; } public bool ForcePublish { get; set; } public bool AppVeyor { get; set; } diff --git a/build/Lifetime.cs b/build/Lifetime.cs index 2e58e8e..fe1e2b4 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -19,6 +19,7 @@ public override void Setup(Context context) context.AzureArtifactsPersonalAccessToken = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN", "mygetapikey"); context.AzureArtifactsSourceName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_NAME", "azureartifactssourcename"); context.AzureArtifactsSourceUserName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_USER_NAME", "azureartifactssourceusername"); + context.GitHubToken = GetEnvironmentValueOrArgument(context, "FROSTING_GITHUB_TOKEN", "githubtoken"); // Directories context.Artifacts = new DirectoryPath("./artifacts"); @@ -28,15 +29,22 @@ public override void Setup(Context context) context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor; context.IsLocalBuild = buildSystem.IsLocalBuild; context.IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; - context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals("cake-build/frosting", buildSystem.AppVeyor.Environment.Repository.Name); + context.PrimaryBranchName = "master"; + context.RepositoryOwner = "cake-build"; + context.RepositoryName = "frosting"; + context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals(string.Concat(context.RepositoryOwner, "/", context.RepositoryName), buildSystem.AppVeyor.Environment.Repository.Name); context.IsTagged = IsBuildTagged(buildSystem); - context.IsMasterBranch = StringComparer.OrdinalIgnoreCase.Equals("master", buildSystem.AppVeyor.Environment.Repository.Branch); + context.IsPrimaryBranch = StringComparer.OrdinalIgnoreCase.Equals(context.PrimaryBranchName, buildSystem.AppVeyor.Environment.Repository.Branch); context.BuildSystem = buildSystem; // Install tools context.Information("Installing tools..."); ToolInstaller.Install(context, "GitVersion.CommandLine", "4.0.0"); + // Install Global .Net Tools + context.Information("Installing .Net Global Tools..."); + ToolInstaller.DotNetCoreToolInstall(context, "GitReleaseManager.Tool", "0.11.0", "dotnet-gitreleasemanager"); + // Calculate semantic version. context.Version = BuildVersion.Calculate(context); context.Version.Version = context.Argument("version", context.Version.Version); diff --git a/build/Tasks/GitReleaseManager.cs b/build/Tasks/GitReleaseManager.cs new file mode 100644 index 0000000..6b49cac --- /dev/null +++ b/build/Tasks/GitReleaseManager.cs @@ -0,0 +1,25 @@ +using Cake.Common.Tools.GitReleaseManager; +using Cake.Common.Tools.GitReleaseManager.Create; +using Cake.Core; +using Cake.Frosting; + +public class CreateReleaseNotes : FrostingTask +{ + public override void Run(Context context) + { + if (string.IsNullOrEmpty(context.GitHubToken)) + { + throw new CakeException("GitHub Token was not provided."); + } + + var settings = new GitReleaseManagerCreateSettings + { + Milestone = context.Version.Milestone, + Name = context.Version.Milestone, + TargetCommitish = context.PrimaryBranchName, + Prerelease = false + }; + + context.GitReleaseManagerCreate(context.GitHubToken, context.RepositoryOwner, context.RepositoryName, settings); + } +} diff --git a/build/Tasks/PublishAzureArtifacts.cs b/build/Tasks/PublishAzureArtifacts.cs index c91e348..c3c8ba1 100644 --- a/build/Tasks/PublishAzureArtifacts.cs +++ b/build/Tasks/PublishAzureArtifacts.cs @@ -1,61 +1,61 @@ -using Cake.Common.Tools.NuGet; -using Cake.Common.Tools.NuGet.Push; -using Cake.Common.Tools.NuGet.Sources; -using Cake.Core; -using Cake.Core.IO; -using Cake.Frosting; - -[Dependency(typeof(Package))] -[Dependency(typeof(AppVeyorArtifacts))] -public class PublishAzureArtifacts : FrostingTask -{ - public override bool ShouldRun(Context context) - { - return !context.IsLocalBuild && !context.IsPullRequest && context.IsOriginalRepo - && (context.IsTagged || !context.IsMasterBranch); - } - - public override void Run(Context context) - { - if(context.AzureArtifactsSourceUrl == null) - { - throw new CakeException("Azure Artifacts source URL was not provided."); - } - if(context.AzureArtifactsSourceName == null) - { - throw new CakeException("Azure Artifacts source name was not provided."); - } - if(context.AzureArtifactsPersonalAccessToken == null) - { - throw new CakeException("Azure Artifacts Personal Access Token was not provided."); - } - if(context.AzureArtifactsSourceUserName == null) - { - throw new CakeException("Azure Artifacts username was not provided."); - } - - // Get the file paths. - var root = new DirectoryPath("./src/Cake.Frosting"); - var files = new[] { - $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg" - }; - - if(!context.NuGetHasSource(context.AzureArtifactsSourceName)) - { - context.NuGetAddSource(context.AzureArtifactsSourceName, context.AzureArtifactsSourceUrl, new NuGetSourcesSettings{ - UserName = context.AzureArtifactsSourceUserName, - Password = context.AzureArtifactsPersonalAccessToken - }); - } - - // Push files - foreach(var file in files) - { - context.NuGetPush(file, new NuGetPushSettings { - Source = context.AzureArtifactsSourceName, - ApiKey = "az" - }); - } - } -} +using Cake.Common.Tools.NuGet; +using Cake.Common.Tools.NuGet.Push; +using Cake.Common.Tools.NuGet.Sources; +using Cake.Core; +using Cake.Core.IO; +using Cake.Frosting; + +[Dependency(typeof(Package))] +[Dependency(typeof(AppVeyorArtifacts))] +public class PublishAzureArtifacts : FrostingTask +{ + public override bool ShouldRun(Context context) + { + return !context.IsLocalBuild && !context.IsPullRequest && context.IsOriginalRepo + && (context.IsTagged || !context.IsPrimaryBranch); + } + + public override void Run(Context context) + { + if(context.AzureArtifactsSourceUrl == null) + { + throw new CakeException("Azure Artifacts source URL was not provided."); + } + if(context.AzureArtifactsSourceName == null) + { + throw new CakeException("Azure Artifacts source name was not provided."); + } + if(context.AzureArtifactsPersonalAccessToken == null) + { + throw new CakeException("Azure Artifacts Personal Access Token was not provided."); + } + if(context.AzureArtifactsSourceUserName == null) + { + throw new CakeException("Azure Artifacts username was not provided."); + } + + // Get the file paths. + var root = new DirectoryPath("./src/Cake.Frosting"); + var files = new[] { + $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg" + }; + + if(!context.NuGetHasSource(context.AzureArtifactsSourceName)) + { + context.NuGetAddSource(context.AzureArtifactsSourceName, context.AzureArtifactsSourceUrl, new NuGetSourcesSettings{ + UserName = context.AzureArtifactsSourceUserName, + Password = context.AzureArtifactsPersonalAccessToken + }); + } + + // Push files + foreach(var file in files) + { + context.NuGetPush(file, new NuGetPushSettings { + Source = context.AzureArtifactsSourceName, + ApiKey = "az" + }); + } + } +} diff --git a/build/Utilities/BuildVersion.cs b/build/Utilities/BuildVersion.cs index adc7e0c..3f9c0ec 100644 --- a/build/Utilities/BuildVersion.cs +++ b/build/Utilities/BuildVersion.cs @@ -7,17 +7,29 @@ public class BuildVersion { public string Version { get; set; } public string SemVersion { get; set; } + public string Milestone { get; private set; } + public string InformationalVersion { get; private set; } + public string FullSemVersion { get; private set; } + public string AssemblySemVer { get; private set; } - public BuildVersion(string version, string semVersion) + public BuildVersion(string version, string semVersion, string informationalVersion, string assemblySemVer, string milestone, string fullSemVersion) { Version = version; SemVersion = semVersion; + InformationalVersion = informationalVersion; + AssemblySemVer = assemblySemVer; + Milestone = milestone; + FullSemVersion = fullSemVersion; } public static BuildVersion Calculate(Context context) { string version = null; string semVersion = null; + string milestone = null; + string informationalVersion = null; + string assemblySemVer = null; + string fullSemVersion = null; if (context.IsRunningOnWindows()) { @@ -36,6 +48,10 @@ public static BuildVersion Calculate(Context context) }); version = assertedVersions.MajorMinorPatch; semVersion = assertedVersions.LegacySemVerPadded; + informationalVersion = assertedVersions.InformationalVersion; + assemblySemVer = assertedVersions.AssemblySemVer; + milestone = string.Concat("v", version); + fullSemVersion = assertedVersions.FullSemVer; } if (string.IsNullOrWhiteSpace(version)) @@ -43,6 +59,6 @@ public static BuildVersion Calculate(Context context) throw new CakeException("Could not calculate version of build."); } - return new BuildVersion(version, semVersion); + return new BuildVersion(version, semVersion, informationalVersion, assemblySemVer, milestone, fullSemVersion); } } \ No newline at end of file diff --git a/build/Utilities/ToolInstaller.cs b/build/Utilities/ToolInstaller.cs index 39248e4..12c1dac 100644 --- a/build/Utilities/ToolInstaller.cs +++ b/build/Utilities/ToolInstaller.cs @@ -1,15 +1,76 @@ +using Cake.Common.IO; +using Cake.Common.Tools.DotNetCore; +using Cake.Common.Tools.DotNetCore.Tool; using Cake.Common.Tools.NuGet; using Cake.Common.Tools.NuGet.Install; using Cake.Core; +using Cake.Core.IO; public static class ToolInstaller { + private static DirectoryPath ToolsPath { get; } = "./tools"; + public static void Install(ICakeContext context, string package, string version) { context.NuGetInstall(package, new NuGetInstallSettings { Version = version, ExcludeVersion = true, - OutputDirectory = "./tools" + OutputDirectory = ToolsPath }); } -} \ No newline at end of file + + public static FilePath DotNetCoreToolInstall( + this ICakeContext context, + string package, + string version, + string toolName) + { + context.EnsureDirectoryExists(ToolsPath); + + var toolsPath = context.MakeAbsolute(ToolsPath); + + var toolInstallPath = toolsPath + .Combine(".store") + .Combine(package.ToLowerInvariant()) + .Combine(version.ToLowerInvariant()); + + var toolPath = toolsPath.CombineWithFilePath( + string.Concat( + toolName, + context.Environment.Platform.IsUnix() + ? string.Empty + : ".exe" + ) + ); + + if (!context.DirectoryExists(toolInstallPath) && context.FileExists(toolPath)) + { + context.DotNetCoreTool("tool", new DotNetCoreToolSettings + { + ArgumentCustomization = args => args + .Append("uninstall") + .AppendSwitchQuoted("--tool-path", toolsPath.FullPath) + .AppendQuoted(package) + }); + } + + if (!context.FileExists(toolPath)) + { + context.DotNetCoreTool("tool", new DotNetCoreToolSettings + { + ArgumentCustomization = args => args + .Append("install") + .AppendSwitchQuoted("--version", version) + .AppendSwitchQuoted("--tool-path", toolsPath.FullPath) + .AppendQuoted(package) + }); + } + + if (!context.FileExists(toolPath)) + { + throw new System.Exception($"Failed to install .NET Core tool {package} ({version})."); + } + + return toolPath; + } +} From a2e06cc1397a8455057cc7a00f54f40f50b3d63d Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sun, 28 Jun 2020 20:16:52 +0100 Subject: [PATCH 09/48] (GH-78) Corrected name of file --- build/Tasks/{GitReleaseManager.cs => CreateReleaseNotes.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename build/Tasks/{GitReleaseManager.cs => CreateReleaseNotes.cs} (100%) diff --git a/build/Tasks/GitReleaseManager.cs b/build/Tasks/CreateReleaseNotes.cs similarity index 100% rename from build/Tasks/GitReleaseManager.cs rename to build/Tasks/CreateReleaseNotes.cs From 337ce0e42be538479f6854ce3ac2d78ee3e24c6a Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sun, 28 Jun 2020 20:17:59 +0100 Subject: [PATCH 10/48] (GH-78) Add task to publish GitHub Release This will add all the assets, similar to what are uploaded to AppVeyor, to the GitHub Release, when tagged and on the primary branch. It will also close the milestone associated with the release. --- build/Tasks/AppVeyor.cs | 1 + build/Tasks/PublishGitHubRelease.cs | 41 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 build/Tasks/PublishGitHubRelease.cs diff --git a/build/Tasks/AppVeyor.cs b/build/Tasks/AppVeyor.cs index bf11a86..e5a96f0 100644 --- a/build/Tasks/AppVeyor.cs +++ b/build/Tasks/AppVeyor.cs @@ -2,6 +2,7 @@ [Dependency(typeof(AppVeyorArtifacts))] [Dependency(typeof(PublishAzureArtifacts))] +[Dependency(typeof(PublishGitHubRelease))] public class AppVeyor : FrostingTask { public override bool ShouldRun(Context context) diff --git a/build/Tasks/PublishGitHubRelease.cs b/build/Tasks/PublishGitHubRelease.cs new file mode 100644 index 0000000..6dd88f8 --- /dev/null +++ b/build/Tasks/PublishGitHubRelease.cs @@ -0,0 +1,41 @@ +using Cake.Common.Tools.GitReleaseManager; +using Cake.Core; +using Cake.Core.IO; +using Cake.Frosting; + +[Dependency(typeof(Package))] +public class PublishGitHubRelease : FrostingTask +{ + public override bool ShouldRun(Context context) + { + return !context.IsLocalBuild && + !context.IsPullRequest && + context.IsOriginalRepo && + context.IsPrimaryBranch && + context.IsTagged; + } + + public override void Run(Context context) + { + if (string.IsNullOrEmpty(context.GitHubToken)) + { + throw new CakeException("GitHub Token was not provided."); + } + + // Get the file paths. + var root = new DirectoryPath("./src/Cake.Frosting"); + var files = new[] { + $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.snupkg" + }; + + // Concatenating FilePathCollections should make sure we get unique FilePaths + foreach (var file in files) + { + context.GitReleaseManagerAddAssets(context.GitHubToken, context.RepositoryOwner, context.RepositoryName, context.Version.Milestone, file); + } + + context.GitReleaseManagerClose(context.GitHubToken, context.RepositoryOwner, context.RepositoryName, context.Version.Milestone); + } +} From 944a8962dd664da9b05b0dee948f85a1d3a8894e Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sun, 28 Jun 2020 21:37:58 +0100 Subject: [PATCH 11/48] (GH-89) Sign all NuGet packages This is done before publishing them anywhere, and only done when doing a release, i.e on the primary branch and is tagged. --- build/Lifetime.cs | 1 + build/Tasks/AppVeyorArtifacts.cs | 69 +++++++++++++-------------- build/Tasks/PublishGitHubRelease.cs | 1 + build/Tasks/SignFiles.cs | 73 +++++++++++++++++++++++++++++ signclient.filter | 1 + signclient.json | 13 +++++ 6 files changed, 124 insertions(+), 34 deletions(-) create mode 100644 build/Tasks/SignFiles.cs create mode 100644 signclient.filter create mode 100644 signclient.json diff --git a/build/Lifetime.cs b/build/Lifetime.cs index fe1e2b4..57e8990 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -44,6 +44,7 @@ public override void Setup(Context context) // 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"); // Calculate semantic version. context.Version = BuildVersion.Calculate(context); diff --git a/build/Tasks/AppVeyorArtifacts.cs b/build/Tasks/AppVeyorArtifacts.cs index 91ee9b6..98aa0d8 100644 --- a/build/Tasks/AppVeyorArtifacts.cs +++ b/build/Tasks/AppVeyorArtifacts.cs @@ -1,34 +1,35 @@ -using Cake.Common.Tools.NuGet; -using Cake.Common.Tools.NuGet.Push; -using Cake.Core; -using Cake.Core.IO; -using Cake.Frosting; - -[Dependency(typeof(Package))] -public class AppVeyorArtifacts : FrostingTask -{ - public override bool ShouldRun(Context context) - { - return context.AppVeyor; - } - - public override void Run(Context context) - { - // Get the file paths. - var root = new DirectoryPath("./src/Cake.Frosting"); - var files = new[] { - $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.snupkg" - }; - - - // Push files - foreach(var file in files) - { - context.BuildSystem.AppVeyor.UploadArtifact( - file - ); - } - } -} \ No newline at end of file +using Cake.Common.Tools.NuGet; +using Cake.Common.Tools.NuGet.Push; +using Cake.Core; +using Cake.Core.IO; +using Cake.Frosting; + +[Dependency(typeof(Package))] +[Dependency(typeof(SignFiles))] +public class AppVeyorArtifacts : FrostingTask +{ + public override bool ShouldRun(Context context) + { + return context.AppVeyor; + } + + public override void Run(Context context) + { + // Get the file paths. + var root = new DirectoryPath("./src/Cake.Frosting"); + var files = new[] { + $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.snupkg" + }; + + + // Push files + foreach(var file in files) + { + context.BuildSystem.AppVeyor.UploadArtifact( + file + ); + } + } +} diff --git a/build/Tasks/PublishGitHubRelease.cs b/build/Tasks/PublishGitHubRelease.cs index 6dd88f8..60a6da3 100644 --- a/build/Tasks/PublishGitHubRelease.cs +++ b/build/Tasks/PublishGitHubRelease.cs @@ -4,6 +4,7 @@ using Cake.Frosting; [Dependency(typeof(Package))] +[Dependency(typeof(PublishAzureArtifacts))] public class PublishGitHubRelease : FrostingTask { public override bool ShouldRun(Context context) diff --git a/build/Tasks/SignFiles.cs b/build/Tasks/SignFiles.cs new file mode 100644 index 0000000..f0ba5b5 --- /dev/null +++ b/build/Tasks/SignFiles.cs @@ -0,0 +1,73 @@ +using System; +using System.Linq; +using Cake.Common; +using Cake.Common.Diagnostics; +using Cake.Common.IO; +using Cake.Core; +using Cake.Core.IO; +using Cake.Frosting; + +[Dependency(typeof(Package))] +public class SignFiles : FrostingTask +{ + public override bool ShouldRun(Context context) + { + return (!context.IsLocalBuild && + !context.IsPullRequest && + context.IsOriginalRepo && + context.IsPrimaryBranch && + context.IsTagged) || + StringComparer.OrdinalIgnoreCase.Equals(context.EnvironmentVariable("SIGNING_TEST"), "True"); + } + + public override void Run(Context context) + { + var signClientPath = context.Tools.Resolve("SignClient.exe") ?? context.Tools.Resolve("SignClient") ?? throw new Exception("Failed to locate sign tool"); + + // Get the secret. + var secret = context.EnvironmentVariable("SIGNING_SECRET"); + if(string.IsNullOrWhiteSpace(secret)) { + throw new InvalidOperationException("Could not resolve signing secret."); + } + // Get the user. + var user = context.EnvironmentVariable("SIGNING_USER"); + if(string.IsNullOrWhiteSpace(user)) { + throw new InvalidOperationException("Could not resolve signing user."); + } + + var settings = new FilePath("./signclient.json"); + var filter = new FilePath("./signclient.filter"); + + // Get the files to sign. + var files = new[] { + $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.snupkg" + }; + + foreach(var file in files) + { + context.Information("Signing {0}...", file); + + // Build the argument list. + var arguments = new ProcessArgumentBuilder() + .Append("sign") + .AppendSwitchQuoted("-c", context.MakeAbsolute(settings).FullPath) + .AppendSwitchQuoted("-i", context.MakeAbsolute(((FilePath)file)).FullPath) + .AppendSwitchQuoted("-f", context.MakeAbsolute(filter).FullPath) + .AppendSwitchQuotedSecret("-s", secret) + .AppendSwitchQuotedSecret("-r", user) + .AppendSwitchQuoted("-n", "Cake") + .AppendSwitchQuoted("-d", "Cake (C# Make) is a cross platform build automation system.") + .AppendSwitchQuoted("-u", "https://cakebuild.net"); + + // Sign the binary. + var result = context.StartProcess(signClientPath.FullPath, new ProcessSettings { Arguments = arguments }); + if(result != 0) + { + // We should not recover from this. + throw new InvalidOperationException("Signing failed!"); + } + } + } +} diff --git a/signclient.filter b/signclient.filter new file mode 100644 index 0000000..0906d37 --- /dev/null +++ b/signclient.filter @@ -0,0 +1 @@ +**/Cake.* diff --git a/signclient.json b/signclient.json new file mode 100644 index 0000000..fe1c8c9 --- /dev/null +++ b/signclient.json @@ -0,0 +1,13 @@ +{ + "SignClient": { + "AzureAd": { + "AADInstance": "https://login.microsoftonline.com/", + "ClientId": "c248d68a-ba6f-4aa9-8a68-71fe872063f8", + "TenantId": "16076fdc-fcc1-4a15-b1ca-32c9a255900e" + }, + "Service": { + "Url": "https://codesign.dotnetfoundation.org/", + "ResourceId": "https://SignService/3c30251f-36f3-490b-a955-520addb85001" + } + } +} From 9fb63beec1eacb3aee0aa1d91c92ace7fbd09dd4 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sun, 28 Jun 2020 21:46:16 +0100 Subject: [PATCH 12/48] (GH-90) Switch to GitVersion Global Tool Rather than using the full .net framework version. --- build/Lifetime.cs | 162 +++++++++++++++++++++++----------------------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/build/Lifetime.cs b/build/Lifetime.cs index 57e8990..38bdc77 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -1,82 +1,82 @@ -using System; -using Cake.Common; -using Cake.Common.Diagnostics; -using Cake.Common.Build; -using Cake.Common.Tools.DotNetCore.MSBuild; -using Cake.Frosting; -using Cake.Core.Diagnostics; -using Cake.Core.IO; - -public class Lifetime : FrostingLifetime -{ - public override void Setup(Context context) - { - // Arguments - context.Target = context.Argument("target", "Default"); - context.BuildConfiguration = context.Argument("configuration", "Release"); - context.ForcePublish = context.Argument("forcepublish", false); - context.AzureArtifactsSourceUrl = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_URL", "azureartifactssourceurl"); - context.AzureArtifactsPersonalAccessToken = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN", "mygetapikey"); - context.AzureArtifactsSourceName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_NAME", "azureartifactssourcename"); - context.AzureArtifactsSourceUserName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_USER_NAME", "azureartifactssourceusername"); - context.GitHubToken = GetEnvironmentValueOrArgument(context, "FROSTING_GITHUB_TOKEN", "githubtoken"); - - // Directories - context.Artifacts = new DirectoryPath("./artifacts"); - - // Build system information. - var buildSystem = context.BuildSystem(); - context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor; - context.IsLocalBuild = buildSystem.IsLocalBuild; - context.IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; - context.PrimaryBranchName = "master"; - context.RepositoryOwner = "cake-build"; - context.RepositoryName = "frosting"; - context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals(string.Concat(context.RepositoryOwner, "/", context.RepositoryName), buildSystem.AppVeyor.Environment.Repository.Name); - context.IsTagged = IsBuildTagged(buildSystem); - context.IsPrimaryBranch = StringComparer.OrdinalIgnoreCase.Equals(context.PrimaryBranchName, buildSystem.AppVeyor.Environment.Repository.Branch); - context.BuildSystem = buildSystem; - - // Install tools - context.Information("Installing tools..."); - ToolInstaller.Install(context, "GitVersion.CommandLine", "4.0.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"); - - // Calculate semantic version. - context.Version = BuildVersion.Calculate(context); - context.Version.Version = context.Argument("version", context.Version.Version); - context.Version.SemVersion = context.Argument("suffix", context.Version.SemVersion); - - // MSBuild Settings - context.MSBuildSettings = new DotNetCoreMSBuildSettings() - .WithProperty("Version", context.Version.SemVersion) - .WithProperty("AssemblyVersion", context.Version.Version) - .WithProperty("FileVersion", context.Version.Version); - - context.Information("Version: {0}", context.Version); - context.Information("Sem version: {0}", context.Version.SemVersion); - context.Information("Configuration: {0}", context.BuildConfiguration); - context.Information("Target: {0}", context.Target); - context.Information("AppVeyor: {0}", context.AppVeyor); - } - - private static bool IsBuildTagged(BuildSystem buildSystem) - { - return buildSystem.AppVeyor.Environment.Repository.Tag.IsTag - && !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name); - } - - private static string GetEnvironmentValueOrArgument(Context context, string environmentVariable, string argumentName) - { - var arg = context.EnvironmentVariable(environmentVariable); - if (string.IsNullOrWhiteSpace(arg)) - { - arg = context.Argument(argumentName, null); - } - return arg; - } +using System; +using Cake.Common; +using Cake.Common.Diagnostics; +using Cake.Common.Build; +using Cake.Common.Tools.DotNetCore.MSBuild; +using Cake.Frosting; +using Cake.Core.Diagnostics; +using Cake.Core.IO; + +public class Lifetime : FrostingLifetime +{ + public override void Setup(Context context) + { + // Arguments + context.Target = context.Argument("target", "Default"); + context.BuildConfiguration = context.Argument("configuration", "Release"); + context.ForcePublish = context.Argument("forcepublish", false); + context.AzureArtifactsSourceUrl = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_URL", "azureartifactssourceurl"); + context.AzureArtifactsPersonalAccessToken = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN", "mygetapikey"); + context.AzureArtifactsSourceName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_NAME", "azureartifactssourcename"); + context.AzureArtifactsSourceUserName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_USER_NAME", "azureartifactssourceusername"); + context.GitHubToken = GetEnvironmentValueOrArgument(context, "FROSTING_GITHUB_TOKEN", "githubtoken"); + + // Directories + context.Artifacts = new DirectoryPath("./artifacts"); + + // Build system information. + var buildSystem = context.BuildSystem(); + context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor; + context.IsLocalBuild = buildSystem.IsLocalBuild; + context.IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; + context.PrimaryBranchName = "master"; + context.RepositoryOwner = "cake-build"; + context.RepositoryName = "frosting"; + context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals(string.Concat(context.RepositoryOwner, "/", context.RepositoryName), buildSystem.AppVeyor.Environment.Repository.Name); + context.IsTagged = IsBuildTagged(buildSystem); + context.IsPrimaryBranch = StringComparer.OrdinalIgnoreCase.Equals(context.PrimaryBranchName, buildSystem.AppVeyor.Environment.Repository.Branch); + context.BuildSystem = buildSystem; + + // Install tools + context.Information("Installing tools..."); + + // 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") + + // Calculate semantic version. + context.Version = BuildVersion.Calculate(context); + context.Version.Version = context.Argument("version", context.Version.Version); + context.Version.SemVersion = context.Argument("suffix", context.Version.SemVersion); + + // MSBuild Settings + context.MSBuildSettings = new DotNetCoreMSBuildSettings() + .WithProperty("Version", context.Version.SemVersion) + .WithProperty("AssemblyVersion", context.Version.Version) + .WithProperty("FileVersion", context.Version.Version); + + context.Information("Version: {0}", context.Version); + context.Information("Sem version: {0}", context.Version.SemVersion); + context.Information("Configuration: {0}", context.BuildConfiguration); + context.Information("Target: {0}", context.Target); + context.Information("AppVeyor: {0}", context.AppVeyor); + } + + private static bool IsBuildTagged(BuildSystem buildSystem) + { + return buildSystem.AppVeyor.Environment.Repository.Tag.IsTag + && !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name); + } + + private static string GetEnvironmentValueOrArgument(Context context, string environmentVariable, string argumentName) + { + var arg = context.EnvironmentVariable(environmentVariable); + if (string.IsNullOrWhiteSpace(arg)) + { + arg = context.Argument(argumentName, null); + } + return arg; + } } \ No newline at end of file From aedfcc8299cc9ae37a9e3c184b228059f88e498b Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sun, 28 Jun 2020 21:47:40 +0100 Subject: [PATCH 13/48] (GH-90) Fix syntax error Doh! --- build/Lifetime.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Lifetime.cs b/build/Lifetime.cs index 38bdc77..bd133ce 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -44,7 +44,7 @@ public override void Setup(Context context) 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") + ToolInstaller.DotNetCoreToolInstall(context, "GitVersion.Tool", "5.1.2", "dotnet-gitversion"); // Calculate semantic version. context.Version = BuildVersion.Calculate(context); From 20d027a9e3557245cde63527b6d36efd60c1ee63 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sun, 28 Jun 2020 22:07:19 +0100 Subject: [PATCH 14/48] (maint) Remove unnecessary variables --- build/Tasks/AppVeyorArtifacts.cs | 1 - build/Tasks/PublishAzureArtifacts.cs | 1 - build/Tasks/PublishGitHubRelease.cs | 1 - 3 files changed, 3 deletions(-) diff --git a/build/Tasks/AppVeyorArtifacts.cs b/build/Tasks/AppVeyorArtifacts.cs index 98aa0d8..d5210e9 100644 --- a/build/Tasks/AppVeyorArtifacts.cs +++ b/build/Tasks/AppVeyorArtifacts.cs @@ -16,7 +16,6 @@ public override bool ShouldRun(Context context) public override void Run(Context context) { // Get the file paths. - var root = new DirectoryPath("./src/Cake.Frosting"); var files = new[] { $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", diff --git a/build/Tasks/PublishAzureArtifacts.cs b/build/Tasks/PublishAzureArtifacts.cs index c3c8ba1..d413267 100644 --- a/build/Tasks/PublishAzureArtifacts.cs +++ b/build/Tasks/PublishAzureArtifacts.cs @@ -35,7 +35,6 @@ public override void Run(Context context) } // Get the file paths. - var root = new DirectoryPath("./src/Cake.Frosting"); var files = new[] { $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg" diff --git a/build/Tasks/PublishGitHubRelease.cs b/build/Tasks/PublishGitHubRelease.cs index 60a6da3..cc00022 100644 --- a/build/Tasks/PublishGitHubRelease.cs +++ b/build/Tasks/PublishGitHubRelease.cs @@ -24,7 +24,6 @@ public override void Run(Context context) } // Get the file paths. - var root = new DirectoryPath("./src/Cake.Frosting"); var files = new[] { $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", From 600d6f099e7725919a4e1b8da29915c813cf94fb Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sun, 28 Jun 2020 22:08:10 +0100 Subject: [PATCH 15/48] (GH-86) Add task to publish to NuGet This will only happen on a tagged build from primary branch. --- build/Tasks/AppVeyor.cs | 1 + build/Tasks/PublishGitHubRelease.cs | 2 +- build/Tasks/PublishNuGet.cs | 49 +++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 build/Tasks/PublishNuGet.cs diff --git a/build/Tasks/AppVeyor.cs b/build/Tasks/AppVeyor.cs index e5a96f0..649e6b8 100644 --- a/build/Tasks/AppVeyor.cs +++ b/build/Tasks/AppVeyor.cs @@ -2,6 +2,7 @@ [Dependency(typeof(AppVeyorArtifacts))] [Dependency(typeof(PublishAzureArtifacts))] +[Dependency(typeof(PublishNuGet))] [Dependency(typeof(PublishGitHubRelease))] public class AppVeyor : FrostingTask { diff --git a/build/Tasks/PublishGitHubRelease.cs b/build/Tasks/PublishGitHubRelease.cs index cc00022..12633b5 100644 --- a/build/Tasks/PublishGitHubRelease.cs +++ b/build/Tasks/PublishGitHubRelease.cs @@ -4,7 +4,7 @@ using Cake.Frosting; [Dependency(typeof(Package))] -[Dependency(typeof(PublishAzureArtifacts))] +[Dependency(typeof(PublishNuGet))] public class PublishGitHubRelease : FrostingTask { public override bool ShouldRun(Context context) diff --git a/build/Tasks/PublishNuGet.cs b/build/Tasks/PublishNuGet.cs new file mode 100644 index 0000000..edcc6ac --- /dev/null +++ b/build/Tasks/PublishNuGet.cs @@ -0,0 +1,49 @@ +using System; +using Cake.Common; +using Cake.Common.Tools.NuGet; +using Cake.Common.Tools.NuGet.Push; +using Cake.Frosting; + +[Dependency(typeof(Package))] +[Dependency(typeof(PublishAzureArtifacts))] +public class PublishNuGet : FrostingTask +{ + public override bool ShouldRun(Context context) + { + return !context.IsLocalBuild && + !context.IsPullRequest && + context.IsOriginalRepo && + context.IsPrimaryBranch && + context.IsTagged; + } + + public override void Run(Context context) + { + // Resolve the API key. + var apiKey = context.EnvironmentVariable("NUGET_API_KEY"); + if(string.IsNullOrEmpty(apiKey)) { + throw new InvalidOperationException("Could not resolve NuGet API key."); + } + + // Get the packages... + var packages = new[] { + $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", + }; + + // Resolve the API url. + var apiUrl = context.EnvironmentVariable("NUGET_API_URL"); + if(string.IsNullOrEmpty(apiUrl)) { + throw new InvalidOperationException("Could not resolve NuGet API url."); + } + + foreach(var package in packages) + { + // Push the package. + context.NuGetPush(package, new NuGetPushSettings { + ApiKey = apiKey, + Source = apiUrl + }); + } + } +} From dcb9701c8661141a8a48e4414f2a67dfb08812ec Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Mon, 29 Jun 2020 19:31:40 +0200 Subject: [PATCH 16/48] (GH-91) Add code of conduct * fixes #91 --- CODE_OF_CONDUCT.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..021c03b --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,24 @@ +# Contributor Code of Conduct + +As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. + +We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. + +Examples of unacceptable behavior by participants include: + +- The use of sexualized language or imagery +- Personal attacks +- Trolling or insulting/derogatory comments +- Public or private harassment +- Publishing other's private information, such as physical or electronic addresses, without explicit permission +- Other unethical or unprofessional conduct + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting a project maintainer at [caketeam@cakebuild.net](mailto:caketeam@cakebuild.net). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an incident. + +This Code of Conduct is adapted from the Contributor Covenant, version 1.3.0, available from http://contributor-covenant.org/version/1/3/0/ From cad3083dcdbeb208da2569ba804abe1b156d4326 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Tue, 30 Jun 2020 11:21:09 +0200 Subject: [PATCH 17/48] Prepare for GitHub actions --- .github/workflows/build.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..31807f0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,25 @@ +name: Build +on: + pull_request: + push: + branches: + - master + - develop +jobs: + build: + name: Build + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - name: Get the sources + uses: actions/checkout@v2 + + - name: Fetch all history for all tags and branches + run: git fetch --prune --unshallow + + - name: Install .NET Core SDK 3.1.301 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '3.1.301' From 0c2d090a8b3e6db6e079d2348f5f1fa749b19cb2 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sat, 27 Jun 2020 10:09:44 +0100 Subject: [PATCH 18/48] (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 19/48] (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 20/48] (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 21/48] (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 22/48] (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 23/48] (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 24/48] (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 25/48] (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 26/48] (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 27/48] (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 28/48] (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 29/48] (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 30/48] (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 31/48] (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 From 329fbfb2c3beee81d352a2409aa97dc123c67f20 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 1 Jul 2020 20:46:23 +0100 Subject: [PATCH 32/48] (GH-97) Add contributing information Used file from Cake repository as a basis, and tweaked it slightly. --- CONTRIBUTING.md | 164 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b331d9a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,164 @@ +# Contribution Guidelines + +* [Prerequisites](#prerequisites) +* [Definition of trivial contributions](#definition-of-trivial-contributions) +* [Code](#code) + * [Code style](#code-style) + * [Dependencies](#dependencies) + * [Unit tests](#unit-tests) +* [Contributing process](#contributing-process) + * [Get buyoff or find open community issues or features](#get-buyoff-or-find-open-community-issues-or-features) + * [Set up your environment](#Set-up-your-environment) + * [Prepare commits](#prepare-commits) + * [Submit pull request](#Submit-pull-request) + * [Respond to feedback on pull request](#respond-to-feedback-on-pull-request) +* [Other general information](#other-general-information) +* [Acknowledgement](#acknowledgement) + +## Prerequisites + +By contributing to Cake, you assert that: + +* The contribution is your own original work. +* You have the right to assign the copyright for the work (it is not owned by your employer, or + you have been given copyright assignment in writing). +* You [license](https://github.com/cake-build/cake/blob/develop/LICENSE) the contribution under the terms applied to the rest of the Cake project. +* You agree to follow the [code of conduct](https://github.com/cake-build/cake/blob/develop/CODE_OF_CONDUCT.md). + +## Definition of trivial contributions +It's hard to define what is a trivial contribution. Sometimes even a 1 character change can be considered significant. +Unfortunately because it can be subjective, the decision on what is trivial comes from the maintainers of the project +and not from folks contributing to the project. + +What is generally considered trivial: + +* Fixing a typo. +* Documentation changes. +* Fixes to non-production code - like fixing something small in the build code. + +What is generally not considered trivial: + + * Changes to any code that would be delivered as part of the final product. + This includes any scripts that are delivered, such as the PowerShell bootstrapper. + Yes, even 1 character changes could be considered non-trivial. + +## Code +### Code style + +Normal .NET coding guidelines apply. +See the [Framework Design Guidelines](https://msdn.microsoft.com/en-us/library/ms229042%28v=vs.110%29.aspx) for more information. + +### Unit tests + +Make sure to run all unit tests before creating a pull request. +Any new code should also have reasonable unit test coverage. + +## Contributing process +### Get buyoff or find open community issues or features + + * Through GitHub, or through the [Gitter chat](https://gitter.im/cake-build/cake) (preferred), + you talk about a feature you would like to see (or a bug), and why it should be in Cake. + * If approved through the Gitter chat, ensure an accompanying GitHub issue is created with + information and a link back to the discussion. + * Once you get a nod from one of the [Cake Team](https://github.com/cake-build?tab=members), you can start on the feature. + * Alternatively, if a feature is on the issues list with the + [Up For Grabs](https://github.com/cake-build/frosting/labels/up-for-grabs) label, + it is open for a community member (contributor) to patch. You should comment that you are signing up for it on + the issue so someone else doesn't also sign up for the work. + +### Set up your environment + + * You create, or update, a fork of cake-build/frosting under your GitHub account. + * From there you create a branch named specific to the feature. + * In the branch you do work specific to the feature. + * Please also observe the following: + * No reformatting + * No changing files that are not specific to the feature. + * More covered below in the **Prepare commits** section. + * Test your changes and please help us out by updating and implementing some automated tests. + It is recommended that all contributors spend some time looking over the tests in the source code. + You can't go wrong emulating one of the existing tests and then changing it specific to the behavior you are testing. + * Please do not update your branch from the develop unless we ask you to. See the responding to feedback section below. + +### Prepare commits +This section serves to help you understand what makes a good commit. + +A commit should observe the following: + + * A commit is a small logical unit that represents a change. + * Should include new or changed tests relevant to the changes you are making. + * No unnecessary whitespace. Check for whitespace with `git diff --check` and `git diff --cached --check` before commit. + * You can stage parts of a file for commit. + +### Submit pull request +Prerequisites: + + * You are making commits in a feature branch. + * All code should compile without errors or warnings. + * All tests should be passing. + +Submitting PR: + + * Once you feel it is ready, submit the pull request to the `cake-build/frosting` repository against the `develop` branch + unless specifically requested to submit it against another branch. + * In the case of a larger change that is going to require more discussion, + please submit a PR sooner. Waiting until you are ready may mean more changes than you are + interested in if the changes are taking things in a direction the maintainers do not want to go. + * In the pull request, outline what you did and point to specific conversations (as in URLs) + and issues that you are resolving. This is a tremendous help for us in evaluation and acceptance. + * Once the pull request is in, please do not delete the branch or close the pull request + (unless something is wrong with it). + * One of the Cake team members, or one of the maintainers, will evaluate it within a + reasonable time period (which is to say usually within 1-3 weeks). Some things get evaluated + faster or fast tracked. We are human and we have active lives outside of open source so don't + fret if you haven't seen any activity on your pull request within a month or two. + We don't have a Service Level Agreement (SLA) for pull requests. + Just know that we will evaluate your pull request. + +### Respond to feedback on pull request + +We may have feedback for you to fix or change some things. We generally like to see that pushed against +the same topic branch (it will automatically update the Pull Request). You can also fix/squash/rebase +commits and push the same topic branch with `--force` (it's generally acceptable to do this on topic +branches not in the main repository, it is generally unacceptable and should be avoided at all costs +against the main repository). + +If we have comments or questions when we do evaluate it and receive no response, it will probably +lessen the chance of getting accepted. Eventually, this means it will be closed if it is not accepted. +Please know this doesn't mean we don't value your contribution, just that things go stale. If in the +future you want to pick it back up, feel free to address our concerns/questions/feedback and reopen +the issue/open a new PR (referencing old one). + +Sometimes we may need you to rebase your commit against the latest code before we can review it further. +If this happens, you can do the following: + + * `git fetch upstream` (upstream would be the mainstream repo or `cake-build/frosting` in this case) + * `git checkout develop` + * `git rebase upstream/develop` + * `git checkout your-branch` + * `git rebase develop` + * Fix any merge conflicts + * `git push origin your-branch` (origin would be your GitHub repo or `your-github-username/cake` in this case). + You may need to `git push origin your-branch --force` to get the commits pushed. + This is generally acceptable with topic branches not in the mainstream repository. + +The only reasons a pull request should be closed and resubmitted are as follows: + + * When the pull request is targeting the wrong branch (this doesn't happen as often). + * When there are updates made to the original by someone other than the original contributor. + Then the old branch is closed with a note on the newer branch this supersedes #github_number. + +## Other general information +If you reformat code or hit core functionality without an approval from a person on the Cake Team, +it's likely that no matter how awesome it looks afterwards, it will probably not get accepted. +Reformatting code makes it harder for us to evaluate exactly what was changed. + +If you do these things, it will be make evaluation and acceptance easy. +Now if you stray outside of the guidelines we have above, it doesn't mean we are going to ignore +your pull request. It will just make things harder for us. +Harder for us roughly translates to a longer SLA for your pull request. + +## Acknowledgement + +This contribution guide was taken from the [Chocolatey project](https://chocolatey.org/) +with permission and was edited to follow Cake's conventions and processes. From ac28004c77f2b93454715c39a2765fe36d26d984 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 1 Jul 2020 20:49:05 +0100 Subject: [PATCH 33/48] (GH-100) Add RunWorkingDirectory property This is similar to a change made within Frosting's own build process. --- template/Build.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/template/Build.csproj b/template/Build.csproj index 8d5d411..24941ea 100644 --- a/template/Build.csproj +++ b/template/Build.csproj @@ -3,6 +3,9 @@ Exe netcoreapp3.0 + + + $(MSBuildProjectDirectory) From 8721db95c2f6ee9bc54d47f6c826d6f5c893ba93 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 1 Jul 2020 20:49:41 +0100 Subject: [PATCH 34/48] (build) Bump to newest version of Cake.Frosting --- template/Build.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/Build.csproj b/template/Build.csproj index 24941ea..04460f5 100644 --- a/template/Build.csproj +++ b/template/Build.csproj @@ -9,7 +9,7 @@ - + From 06c3fea9896acd91b9cf36c5c98c72adc566d32d Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 1 Jul 2020 20:54:37 +0100 Subject: [PATCH 35/48] (GH-99) Add pull request template --- .github/PULL_REQUEST_TEMPLATE | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE new file mode 100644 index 0000000..b289495 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE @@ -0,0 +1,13 @@ + From 0bfc450f155f9a961e97eca9b63af2ff506e1e4d Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 1 Jul 2020 20:56:50 +0100 Subject: [PATCH 36/48] (maint) Fix name of template --- .github/{PULL_REQUEST_TEMPLATE => PULL_REQUEST_TEMPLATE.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{PULL_REQUEST_TEMPLATE => PULL_REQUEST_TEMPLATE.md} (100%) diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from .github/PULL_REQUEST_TEMPLATE rename to .github/PULL_REQUEST_TEMPLATE.md From 9aaf500f02a1518c326306ccf9b2da7976fbcf0d Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 1 Jul 2020 21:03:18 +0100 Subject: [PATCH 37/48] (build) Only publish when on Windows in AppVeyor Otherwise there will be conflicts when trying to push the same package version again. --- build/Tasks/PublishAzureArtifacts.cs | 9 +++++++-- build/Tasks/PublishGitHubRelease.cs | 2 ++ build/Tasks/PublishNuGet.cs | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/build/Tasks/PublishAzureArtifacts.cs b/build/Tasks/PublishAzureArtifacts.cs index d413267..e9209c7 100644 --- a/build/Tasks/PublishAzureArtifacts.cs +++ b/build/Tasks/PublishAzureArtifacts.cs @@ -11,8 +11,13 @@ public class PublishAzureArtifacts : FrostingTask { public override bool ShouldRun(Context context) { - return !context.IsLocalBuild && !context.IsPullRequest && context.IsOriginalRepo - && (context.IsTagged || !context.IsPrimaryBranch); + return + !context.IsLocalBuild && + !context.IsPullRequest && + context.IsOriginalRepo && + context.BuildSystem.IsRunningOnAppVeyor && + context.Environment.Platform.Family == PlatformFamily.Windows && + (context.IsTagged || !context.IsPrimaryBranch); } public override void Run(Context context) diff --git a/build/Tasks/PublishGitHubRelease.cs b/build/Tasks/PublishGitHubRelease.cs index 12633b5..d0b5350 100644 --- a/build/Tasks/PublishGitHubRelease.cs +++ b/build/Tasks/PublishGitHubRelease.cs @@ -13,6 +13,8 @@ public override bool ShouldRun(Context context) !context.IsPullRequest && context.IsOriginalRepo && context.IsPrimaryBranch && + context.BuildSystem.IsRunningOnAppVeyor && + context.Environment.Platform.Family == PlatformFamily.Windows && context.IsTagged; } diff --git a/build/Tasks/PublishNuGet.cs b/build/Tasks/PublishNuGet.cs index edcc6ac..808dc23 100644 --- a/build/Tasks/PublishNuGet.cs +++ b/build/Tasks/PublishNuGet.cs @@ -14,6 +14,8 @@ public override bool ShouldRun(Context context) !context.IsPullRequest && context.IsOriginalRepo && context.IsPrimaryBranch && + context.BuildSystem.IsRunningOnAppVeyor && + context.Environment.Platform.Family == PlatformFamily.Windows && context.IsTagged; } From 8a8fad5a7b731ca195b7e94eca46c0fe5a8545f5 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 1 Jul 2020 21:06:48 +0100 Subject: [PATCH 38/48] (build) Fix build error --- build/Tasks/PublishNuGet.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/build/Tasks/PublishNuGet.cs b/build/Tasks/PublishNuGet.cs index 808dc23..e32357d 100644 --- a/build/Tasks/PublishNuGet.cs +++ b/build/Tasks/PublishNuGet.cs @@ -2,6 +2,7 @@ using Cake.Common; using Cake.Common.Tools.NuGet; using Cake.Common.Tools.NuGet.Push; +using Cake.Core; using Cake.Frosting; [Dependency(typeof(Package))] From 6a33288fef0a89d30b9ada5f7e7768c82b9ade92 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 2 Jul 2020 21:33:56 +0100 Subject: [PATCH 39/48] (GH-72) Ensure deterministic dll genration As suggested by warning in NuGet Package Explorer. --- build/Lifetime.cs | 209 ++++++++++++++++++++++++---------------------- 1 file changed, 107 insertions(+), 102 deletions(-) diff --git a/build/Lifetime.cs b/build/Lifetime.cs index f2383ed..28e4107 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -1,102 +1,107 @@ -using System; -using System.Linq; -using Cake.Common; -using Cake.Common.Diagnostics; -using Cake.Common.Build; -using Cake.Common.Tools.DotNetCore.MSBuild; -using Cake.Frosting; -using Cake.Core.Diagnostics; -using Cake.Core.IO; - -public class Lifetime : FrostingLifetime -{ - public override void Setup(Context context) - { - // Arguments - context.Target = context.Argument("target", "Default"); - context.BuildConfiguration = context.Argument("configuration", "Release"); - context.ForcePublish = context.Argument("forcepublish", false); - context.AzureArtifactsSourceUrl = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_URL", "azureartifactssourceurl"); - context.AzureArtifactsPersonalAccessToken = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN", "mygetapikey"); - context.AzureArtifactsSourceName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_NAME", "azureartifactssourcename"); - context.AzureArtifactsSourceUserName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_USER_NAME", "azureartifactssourceusername"); - context.GitHubToken = GetEnvironmentValueOrArgument(context, "FROSTING_GITHUB_TOKEN", "githubtoken"); - - // Directories - context.Artifacts = new DirectoryPath("./artifacts"); - - // Build system information. - var buildSystem = context.BuildSystem(); - context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor; - context.IsLocalBuild = buildSystem.IsLocalBuild; - context.IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; - context.PrimaryBranchName = "master"; - context.RepositoryOwner = "cake-build"; - context.RepositoryName = "frosting"; - context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals(string.Concat(context.RepositoryOwner, "/", context.RepositoryName), buildSystem.AppVeyor.Environment.Repository.Name); - context.IsTagged = IsBuildTagged(buildSystem); - context.IsPrimaryBranch = StringComparer.OrdinalIgnoreCase.Equals(context.PrimaryBranchName, buildSystem.AppVeyor.Environment.Repository.Branch); - context.BuildSystem = buildSystem; - - // Install tools - context.Information("Installing tools..."); - context.InstallNuGetExe("5.6.0"); - - // Install Global .Net Tools - context.Information("Installing .Net Global Tools..."); - 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); - context.Version.Version = context.Argument("version", context.Version.Version); - context.Version.SemVersion = context.Argument("suffix", context.Version.SemVersion); - - // MSBuild Settings - context.MSBuildSettings = new DotNetCoreMSBuildSettings() - .WithProperty("Version", context.Version.SemVersion) - .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); - context.Information("Target: {0}", context.Target); - context.Information("AppVeyor: {0}", context.AppVeyor); - } - - private static bool IsBuildTagged(BuildSystem buildSystem) - { - return buildSystem.AppVeyor.Environment.Repository.Tag.IsTag - && !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name); - } - - private static string GetEnvironmentValueOrArgument(Context context, string environmentVariable, string argumentName) - { - var arg = context.EnvironmentVariable(environmentVariable); - if (string.IsNullOrWhiteSpace(arg)) - { - arg = context.Argument(argumentName, null); - } - return arg; - } -} +using System; +using System.Linq; +using Cake.Common; +using Cake.Common.Diagnostics; +using Cake.Common.Build; +using Cake.Common.Tools.DotNetCore.MSBuild; +using Cake.Frosting; +using Cake.Core.Diagnostics; +using Cake.Core.IO; + +public class Lifetime : FrostingLifetime +{ + public override void Setup(Context context) + { + // Arguments + context.Target = context.Argument("target", "Default"); + context.BuildConfiguration = context.Argument("configuration", "Release"); + context.ForcePublish = context.Argument("forcepublish", false); + context.AzureArtifactsSourceUrl = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_URL", "azureartifactssourceurl"); + context.AzureArtifactsPersonalAccessToken = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN", "mygetapikey"); + context.AzureArtifactsSourceName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_NAME", "azureartifactssourcename"); + context.AzureArtifactsSourceUserName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_USER_NAME", "azureartifactssourceusername"); + context.GitHubToken = GetEnvironmentValueOrArgument(context, "FROSTING_GITHUB_TOKEN", "githubtoken"); + + // Directories + context.Artifacts = new DirectoryPath("./artifacts"); + + // Build system information. + var buildSystem = context.BuildSystem(); + context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor; + context.IsLocalBuild = buildSystem.IsLocalBuild; + context.IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; + context.PrimaryBranchName = "master"; + context.RepositoryOwner = "cake-build"; + context.RepositoryName = "frosting"; + context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals(string.Concat(context.RepositoryOwner, "/", context.RepositoryName), buildSystem.AppVeyor.Environment.Repository.Name); + context.IsTagged = IsBuildTagged(buildSystem); + context.IsPrimaryBranch = StringComparer.OrdinalIgnoreCase.Equals(context.PrimaryBranchName, buildSystem.AppVeyor.Environment.Repository.Branch); + context.BuildSystem = buildSystem; + + // Install tools + context.Information("Installing tools..."); + context.InstallNuGetExe("5.6.0"); + + // Install Global .Net Tools + context.Information("Installing .Net Global Tools..."); + 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); + context.Version.Version = context.Argument("version", context.Version.Version); + context.Version.SemVersion = context.Argument("suffix", context.Version.SemVersion); + + // MSBuild Settings + context.MSBuildSettings = new DotNetCoreMSBuildSettings() + .WithProperty("Version", context.Version.SemVersion) + .WithProperty("AssemblyVersion", context.Version.Version) + .WithProperty("FileVersion", context.Version.Version); + + if (context.AppVeyor) + { + context.MSBuildSettings.WithProperty("ContinuousIntegrationBuild", "true"); + } + + 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); + context.Information("Target: {0}", context.Target); + context.Information("AppVeyor: {0}", context.AppVeyor); + } + + private static bool IsBuildTagged(BuildSystem buildSystem) + { + return buildSystem.AppVeyor.Environment.Repository.Tag.IsTag + && !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name); + } + + private static string GetEnvironmentValueOrArgument(Context context, string environmentVariable, string argumentName) + { + var arg = context.EnvironmentVariable(environmentVariable); + if (string.IsNullOrWhiteSpace(arg)) + { + arg = context.Argument(argumentName, null); + } + return arg; + } +} From dfcb7b71e124d71c81662f0a720d13edc108ef4b Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 2 Jul 2020 21:37:01 +0100 Subject: [PATCH 40/48] Revert "(GH-72) Ensure deterministic dll genration" This reverts commit 6a33288fef0a89d30b9ada5f7e7768c82b9ade92. --- build/Lifetime.cs | 209 ++++++++++++++++++++++------------------------ 1 file changed, 102 insertions(+), 107 deletions(-) diff --git a/build/Lifetime.cs b/build/Lifetime.cs index 28e4107..f2383ed 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -1,107 +1,102 @@ -using System; -using System.Linq; -using Cake.Common; -using Cake.Common.Diagnostics; -using Cake.Common.Build; -using Cake.Common.Tools.DotNetCore.MSBuild; -using Cake.Frosting; -using Cake.Core.Diagnostics; -using Cake.Core.IO; - -public class Lifetime : FrostingLifetime -{ - public override void Setup(Context context) - { - // Arguments - context.Target = context.Argument("target", "Default"); - context.BuildConfiguration = context.Argument("configuration", "Release"); - context.ForcePublish = context.Argument("forcepublish", false); - context.AzureArtifactsSourceUrl = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_URL", "azureartifactssourceurl"); - context.AzureArtifactsPersonalAccessToken = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN", "mygetapikey"); - context.AzureArtifactsSourceName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_NAME", "azureartifactssourcename"); - context.AzureArtifactsSourceUserName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_USER_NAME", "azureartifactssourceusername"); - context.GitHubToken = GetEnvironmentValueOrArgument(context, "FROSTING_GITHUB_TOKEN", "githubtoken"); - - // Directories - context.Artifacts = new DirectoryPath("./artifacts"); - - // Build system information. - var buildSystem = context.BuildSystem(); - context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor; - context.IsLocalBuild = buildSystem.IsLocalBuild; - context.IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; - context.PrimaryBranchName = "master"; - context.RepositoryOwner = "cake-build"; - context.RepositoryName = "frosting"; - context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals(string.Concat(context.RepositoryOwner, "/", context.RepositoryName), buildSystem.AppVeyor.Environment.Repository.Name); - context.IsTagged = IsBuildTagged(buildSystem); - context.IsPrimaryBranch = StringComparer.OrdinalIgnoreCase.Equals(context.PrimaryBranchName, buildSystem.AppVeyor.Environment.Repository.Branch); - context.BuildSystem = buildSystem; - - // Install tools - context.Information("Installing tools..."); - context.InstallNuGetExe("5.6.0"); - - // Install Global .Net Tools - context.Information("Installing .Net Global Tools..."); - 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); - context.Version.Version = context.Argument("version", context.Version.Version); - context.Version.SemVersion = context.Argument("suffix", context.Version.SemVersion); - - // MSBuild Settings - context.MSBuildSettings = new DotNetCoreMSBuildSettings() - .WithProperty("Version", context.Version.SemVersion) - .WithProperty("AssemblyVersion", context.Version.Version) - .WithProperty("FileVersion", context.Version.Version); - - if (context.AppVeyor) - { - context.MSBuildSettings.WithProperty("ContinuousIntegrationBuild", "true"); - } - - 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); - context.Information("Target: {0}", context.Target); - context.Information("AppVeyor: {0}", context.AppVeyor); - } - - private static bool IsBuildTagged(BuildSystem buildSystem) - { - return buildSystem.AppVeyor.Environment.Repository.Tag.IsTag - && !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name); - } - - private static string GetEnvironmentValueOrArgument(Context context, string environmentVariable, string argumentName) - { - var arg = context.EnvironmentVariable(environmentVariable); - if (string.IsNullOrWhiteSpace(arg)) - { - arg = context.Argument(argumentName, null); - } - return arg; - } -} +using System; +using System.Linq; +using Cake.Common; +using Cake.Common.Diagnostics; +using Cake.Common.Build; +using Cake.Common.Tools.DotNetCore.MSBuild; +using Cake.Frosting; +using Cake.Core.Diagnostics; +using Cake.Core.IO; + +public class Lifetime : FrostingLifetime +{ + public override void Setup(Context context) + { + // Arguments + context.Target = context.Argument("target", "Default"); + context.BuildConfiguration = context.Argument("configuration", "Release"); + context.ForcePublish = context.Argument("forcepublish", false); + context.AzureArtifactsSourceUrl = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_URL", "azureartifactssourceurl"); + context.AzureArtifactsPersonalAccessToken = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN", "mygetapikey"); + context.AzureArtifactsSourceName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_NAME", "azureartifactssourcename"); + context.AzureArtifactsSourceUserName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_USER_NAME", "azureartifactssourceusername"); + context.GitHubToken = GetEnvironmentValueOrArgument(context, "FROSTING_GITHUB_TOKEN", "githubtoken"); + + // Directories + context.Artifacts = new DirectoryPath("./artifacts"); + + // Build system information. + var buildSystem = context.BuildSystem(); + context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor; + context.IsLocalBuild = buildSystem.IsLocalBuild; + context.IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; + context.PrimaryBranchName = "master"; + context.RepositoryOwner = "cake-build"; + context.RepositoryName = "frosting"; + context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals(string.Concat(context.RepositoryOwner, "/", context.RepositoryName), buildSystem.AppVeyor.Environment.Repository.Name); + context.IsTagged = IsBuildTagged(buildSystem); + context.IsPrimaryBranch = StringComparer.OrdinalIgnoreCase.Equals(context.PrimaryBranchName, buildSystem.AppVeyor.Environment.Repository.Branch); + context.BuildSystem = buildSystem; + + // Install tools + context.Information("Installing tools..."); + context.InstallNuGetExe("5.6.0"); + + // Install Global .Net Tools + context.Information("Installing .Net Global Tools..."); + 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); + context.Version.Version = context.Argument("version", context.Version.Version); + context.Version.SemVersion = context.Argument("suffix", context.Version.SemVersion); + + // MSBuild Settings + context.MSBuildSettings = new DotNetCoreMSBuildSettings() + .WithProperty("Version", context.Version.SemVersion) + .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); + context.Information("Target: {0}", context.Target); + context.Information("AppVeyor: {0}", context.AppVeyor); + } + + private static bool IsBuildTagged(BuildSystem buildSystem) + { + return buildSystem.AppVeyor.Environment.Repository.Tag.IsTag + && !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name); + } + + private static string GetEnvironmentValueOrArgument(Context context, string environmentVariable, string argumentName) + { + var arg = context.EnvironmentVariable(environmentVariable); + if (string.IsNullOrWhiteSpace(arg)) + { + arg = context.Argument(argumentName, null); + } + return arg; + } +} From 496388f594208456e741985e0bc1918845a13d04 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 2 Jul 2020 21:44:03 +0100 Subject: [PATCH 41/48] (GH-77) Update badges --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index bc84514..88abdf7 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # Frosting -[![AppVeyor branch](https://img.shields.io/appveyor/ci/cakebuild/frosting/develop.svg)](https://ci.appveyor.com/project/cakebuild/frosting/branch/develop) -[![MyGet](https://img.shields.io/myget/cake/vpre/Cake.Frosting.svg?label=myget)](https://www.myget.org/feed/cake/package/nuget/Cake.Frosting) -[![NuGet](https://img.shields.io/nuget/v/Cake.Frosting.svg)](https://www.nuget.org/packages/Cake.Frosting) +[![NuGet](https://img.shields.io/nuget/v/Cake.Frosting.svg)](https://www.nuget.org/packages/Cake.Frosting) [![Azure Artifacts](https://azpkgsshield.azurevoodoo.net/cake-build/Cake/cake/cake.frosting)](https://dev.azure.com/cake-build/Cake/_packaging?_a=package&feed=cake&package=Cake.Frosting&protocolType=NuGet) A .NET Core host for Cake, that allows you to write your build scripts as a (portable) console application (`netcoreapp2.0` or `net461`). Frosting is currently From aaf64d3130e737dd4ccb7b579fb0cff03d39fb38 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 2 Jul 2020 21:53:18 +0100 Subject: [PATCH 42/48] (GH-71) Switch to embedded pdb Rather than generating a snupkg file. --- src/Cake.Frosting/Cake.Frosting.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cake.Frosting/Cake.Frosting.csproj b/src/Cake.Frosting/Cake.Frosting.csproj index 52f3315..7669999 100644 --- a/src/Cake.Frosting/Cake.Frosting.csproj +++ b/src/Cake.Frosting/Cake.Frosting.csproj @@ -17,9 +17,9 @@ false false 7.2 + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + true true - true - snupkg $(DefineConstants);NETCORE From ed1e8c94350c737b4144e00f6512550443809fe0 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 2 Jul 2020 22:05:45 +0100 Subject: [PATCH 43/48] (GH-72) Ensure deterministic dll genration As suggested by warning in NuGet Package Explorer. --- build/Build.csproj | 4 + build/Lifetime.cs | 209 +++++++++--------- .../Cake.Frosting.Example.csproj | 4 + .../Cake.Frosting.Tests.csproj | 4 + 4 files changed, 119 insertions(+), 102 deletions(-) diff --git a/build/Build.csproj b/build/Build.csproj index a03fc30..53e57c2 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -6,10 +6,14 @@ $(MSBuildProjectDirectory) + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + true + true + diff --git a/build/Lifetime.cs b/build/Lifetime.cs index f2383ed..10b9352 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -1,102 +1,107 @@ -using System; -using System.Linq; -using Cake.Common; -using Cake.Common.Diagnostics; -using Cake.Common.Build; -using Cake.Common.Tools.DotNetCore.MSBuild; -using Cake.Frosting; -using Cake.Core.Diagnostics; -using Cake.Core.IO; - -public class Lifetime : FrostingLifetime -{ - public override void Setup(Context context) - { - // Arguments - context.Target = context.Argument("target", "Default"); - context.BuildConfiguration = context.Argument("configuration", "Release"); - context.ForcePublish = context.Argument("forcepublish", false); - context.AzureArtifactsSourceUrl = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_URL", "azureartifactssourceurl"); - context.AzureArtifactsPersonalAccessToken = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN", "mygetapikey"); - context.AzureArtifactsSourceName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_NAME", "azureartifactssourcename"); - context.AzureArtifactsSourceUserName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_USER_NAME", "azureartifactssourceusername"); - context.GitHubToken = GetEnvironmentValueOrArgument(context, "FROSTING_GITHUB_TOKEN", "githubtoken"); - - // Directories - context.Artifacts = new DirectoryPath("./artifacts"); - - // Build system information. - var buildSystem = context.BuildSystem(); - context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor; - context.IsLocalBuild = buildSystem.IsLocalBuild; - context.IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; - context.PrimaryBranchName = "master"; - context.RepositoryOwner = "cake-build"; - context.RepositoryName = "frosting"; - context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals(string.Concat(context.RepositoryOwner, "/", context.RepositoryName), buildSystem.AppVeyor.Environment.Repository.Name); - context.IsTagged = IsBuildTagged(buildSystem); - context.IsPrimaryBranch = StringComparer.OrdinalIgnoreCase.Equals(context.PrimaryBranchName, buildSystem.AppVeyor.Environment.Repository.Branch); - context.BuildSystem = buildSystem; - - // Install tools - context.Information("Installing tools..."); - context.InstallNuGetExe("5.6.0"); - - // Install Global .Net Tools - context.Information("Installing .Net Global Tools..."); - 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); - context.Version.Version = context.Argument("version", context.Version.Version); - context.Version.SemVersion = context.Argument("suffix", context.Version.SemVersion); - - // MSBuild Settings - context.MSBuildSettings = new DotNetCoreMSBuildSettings() - .WithProperty("Version", context.Version.SemVersion) - .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); - context.Information("Target: {0}", context.Target); - context.Information("AppVeyor: {0}", context.AppVeyor); - } - - private static bool IsBuildTagged(BuildSystem buildSystem) - { - return buildSystem.AppVeyor.Environment.Repository.Tag.IsTag - && !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name); - } - - private static string GetEnvironmentValueOrArgument(Context context, string environmentVariable, string argumentName) - { - var arg = context.EnvironmentVariable(environmentVariable); - if (string.IsNullOrWhiteSpace(arg)) - { - arg = context.Argument(argumentName, null); - } - return arg; - } -} +using System; +using System.Linq; +using Cake.Common; +using Cake.Common.Diagnostics; +using Cake.Common.Build; +using Cake.Common.Tools.DotNetCore.MSBuild; +using Cake.Frosting; +using Cake.Core.Diagnostics; +using Cake.Core.IO; + +public class Lifetime : FrostingLifetime +{ + public override void Setup(Context context) + { + // Arguments + context.Target = context.Argument("target", "Default"); + context.BuildConfiguration = context.Argument("configuration", "Release"); + context.ForcePublish = context.Argument("forcepublish", false); + context.AzureArtifactsSourceUrl = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_URL", "azureartifactssourceurl"); + context.AzureArtifactsPersonalAccessToken = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN", "mygetapikey"); + context.AzureArtifactsSourceName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_NAME", "azureartifactssourcename"); + context.AzureArtifactsSourceUserName = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_USER_NAME", "azureartifactssourceusername"); + context.GitHubToken = GetEnvironmentValueOrArgument(context, "FROSTING_GITHUB_TOKEN", "githubtoken"); + + // Directories + context.Artifacts = new DirectoryPath("./artifacts"); + + // Build system information. + var buildSystem = context.BuildSystem(); + context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor; + context.IsLocalBuild = buildSystem.IsLocalBuild; + context.IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; + context.PrimaryBranchName = "master"; + context.RepositoryOwner = "cake-build"; + context.RepositoryName = "frosting"; + context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals(string.Concat(context.RepositoryOwner, "/", context.RepositoryName), buildSystem.AppVeyor.Environment.Repository.Name); + context.IsTagged = IsBuildTagged(buildSystem); + context.IsPrimaryBranch = StringComparer.OrdinalIgnoreCase.Equals(context.PrimaryBranchName, buildSystem.AppVeyor.Environment.Repository.Branch); + context.BuildSystem = buildSystem; + + // Install tools + context.Information("Installing tools..."); + context.InstallNuGetExe("5.6.0"); + + // Install Global .Net Tools + context.Information("Installing .Net Global Tools..."); + 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); + context.Version.Version = context.Argument("version", context.Version.Version); + context.Version.SemVersion = context.Argument("suffix", context.Version.SemVersion); + + // MSBuild Settings + context.MSBuildSettings = new DotNetCoreMSBuildSettings() + .WithProperty("Version", context.Version.SemVersion) + .WithProperty("AssemblyVersion", context.Version.Version) + .WithProperty("FileVersion", context.Version.Version); + + if(context.AppVeyor) + { + context.MSBuildSettings.WithProperty("ContinuousIntegrationBuild", "true"); + } + + 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); + context.Information("Target: {0}", context.Target); + context.Information("AppVeyor: {0}", context.AppVeyor); + } + + private static bool IsBuildTagged(BuildSystem buildSystem) + { + return buildSystem.AppVeyor.Environment.Repository.Tag.IsTag + && !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name); + } + + private static string GetEnvironmentValueOrArgument(Context context, string environmentVariable, string argumentName) + { + var arg = context.EnvironmentVariable(environmentVariable); + if (string.IsNullOrWhiteSpace(arg)) + { + arg = context.Argument(argumentName, null); + } + return arg; + } +} diff --git a/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj b/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj index ddcbd73..ae9f85e 100644 --- a/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj +++ b/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj @@ -16,11 +16,15 @@ false false 7 + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + true + true + diff --git a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj index 4351435..0ca0daf 100644 --- a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj +++ b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj @@ -10,6 +10,9 @@ https://github.com/cake-build/frosting net461;netcoreapp2.1;netcoreapp3.0 7 + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + true + true @@ -33,6 +36,7 @@ + From 3f3c3cf4c849ff11d92d3374ea1bdbfe1ebf6287 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 2 Jul 2020 22:09:37 +0100 Subject: [PATCH 44/48] (GH-71) Remove publishing of snupkg file This is no longer being generated, and instead the pdb file is embedded into nupkg. --- build/Tasks/AppVeyorArtifacts.cs | 3 +- build/Tasks/PublishGitHubRelease.cs | 3 +- build/Tasks/SignFiles.cs | 145 ++++++++++++++-------------- 3 files changed, 74 insertions(+), 77 deletions(-) diff --git a/build/Tasks/AppVeyorArtifacts.cs b/build/Tasks/AppVeyorArtifacts.cs index d5210e9..0ef5c21 100644 --- a/build/Tasks/AppVeyorArtifacts.cs +++ b/build/Tasks/AppVeyorArtifacts.cs @@ -18,8 +18,7 @@ public override void Run(Context context) // Get the file paths. var files = new[] { $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.snupkg" + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg" }; diff --git a/build/Tasks/PublishGitHubRelease.cs b/build/Tasks/PublishGitHubRelease.cs index d0b5350..896ef9a 100644 --- a/build/Tasks/PublishGitHubRelease.cs +++ b/build/Tasks/PublishGitHubRelease.cs @@ -28,8 +28,7 @@ public override void Run(Context context) // Get the file paths. var files = new[] { $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.snupkg" + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg" }; // Concatenating FilePathCollections should make sure we get unique FilePaths diff --git a/build/Tasks/SignFiles.cs b/build/Tasks/SignFiles.cs index f0ba5b5..58b1c96 100644 --- a/build/Tasks/SignFiles.cs +++ b/build/Tasks/SignFiles.cs @@ -1,73 +1,72 @@ -using System; -using System.Linq; -using Cake.Common; -using Cake.Common.Diagnostics; -using Cake.Common.IO; -using Cake.Core; -using Cake.Core.IO; -using Cake.Frosting; - -[Dependency(typeof(Package))] -public class SignFiles : FrostingTask -{ - public override bool ShouldRun(Context context) - { - return (!context.IsLocalBuild && - !context.IsPullRequest && - context.IsOriginalRepo && - context.IsPrimaryBranch && - context.IsTagged) || - StringComparer.OrdinalIgnoreCase.Equals(context.EnvironmentVariable("SIGNING_TEST"), "True"); - } - - public override void Run(Context context) - { - var signClientPath = context.Tools.Resolve("SignClient.exe") ?? context.Tools.Resolve("SignClient") ?? throw new Exception("Failed to locate sign tool"); - - // Get the secret. - var secret = context.EnvironmentVariable("SIGNING_SECRET"); - if(string.IsNullOrWhiteSpace(secret)) { - throw new InvalidOperationException("Could not resolve signing secret."); - } - // Get the user. - var user = context.EnvironmentVariable("SIGNING_USER"); - if(string.IsNullOrWhiteSpace(user)) { - throw new InvalidOperationException("Could not resolve signing user."); - } - - var settings = new FilePath("./signclient.json"); - var filter = new FilePath("./signclient.filter"); - - // Get the files to sign. - var files = new[] { - $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg", - $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.snupkg" - }; - - foreach(var file in files) - { - context.Information("Signing {0}...", file); - - // Build the argument list. - var arguments = new ProcessArgumentBuilder() - .Append("sign") - .AppendSwitchQuoted("-c", context.MakeAbsolute(settings).FullPath) - .AppendSwitchQuoted("-i", context.MakeAbsolute(((FilePath)file)).FullPath) - .AppendSwitchQuoted("-f", context.MakeAbsolute(filter).FullPath) - .AppendSwitchQuotedSecret("-s", secret) - .AppendSwitchQuotedSecret("-r", user) - .AppendSwitchQuoted("-n", "Cake") - .AppendSwitchQuoted("-d", "Cake (C# Make) is a cross platform build automation system.") - .AppendSwitchQuoted("-u", "https://cakebuild.net"); - - // Sign the binary. - var result = context.StartProcess(signClientPath.FullPath, new ProcessSettings { Arguments = arguments }); - if(result != 0) - { - // We should not recover from this. - throw new InvalidOperationException("Signing failed!"); - } - } - } -} +using System; +using System.Linq; +using Cake.Common; +using Cake.Common.Diagnostics; +using Cake.Common.IO; +using Cake.Core; +using Cake.Core.IO; +using Cake.Frosting; + +[Dependency(typeof(Package))] +public class SignFiles : FrostingTask +{ + public override bool ShouldRun(Context context) + { + return (!context.IsLocalBuild && + !context.IsPullRequest && + context.IsOriginalRepo && + context.IsPrimaryBranch && + context.IsTagged) || + StringComparer.OrdinalIgnoreCase.Equals(context.EnvironmentVariable("SIGNING_TEST"), "True"); + } + + public override void Run(Context context) + { + var signClientPath = context.Tools.Resolve("SignClient.exe") ?? context.Tools.Resolve("SignClient") ?? throw new Exception("Failed to locate sign tool"); + + // Get the secret. + var secret = context.EnvironmentVariable("SIGNING_SECRET"); + if(string.IsNullOrWhiteSpace(secret)) { + throw new InvalidOperationException("Could not resolve signing secret."); + } + // Get the user. + var user = context.EnvironmentVariable("SIGNING_USER"); + if(string.IsNullOrWhiteSpace(user)) { + throw new InvalidOperationException("Could not resolve signing user."); + } + + var settings = new FilePath("./signclient.json"); + var filter = new FilePath("./signclient.filter"); + + // Get the files to sign. + var files = new[] { + $"./artifacts/Cake.Frosting.Template.{context.Version.SemVersion}.nupkg", + $"./artifacts/Cake.Frosting.{context.Version.SemVersion}.nupkg" + }; + + foreach(var file in files) + { + context.Information("Signing {0}...", file); + + // Build the argument list. + var arguments = new ProcessArgumentBuilder() + .Append("sign") + .AppendSwitchQuoted("-c", context.MakeAbsolute(settings).FullPath) + .AppendSwitchQuoted("-i", context.MakeAbsolute(((FilePath)file)).FullPath) + .AppendSwitchQuoted("-f", context.MakeAbsolute(filter).FullPath) + .AppendSwitchQuotedSecret("-s", secret) + .AppendSwitchQuotedSecret("-r", user) + .AppendSwitchQuoted("-n", "Cake") + .AppendSwitchQuoted("-d", "Cake (C# Make) is a cross platform build automation system.") + .AppendSwitchQuoted("-u", "https://cakebuild.net"); + + // Sign the binary. + var result = context.StartProcess(signClientPath.FullPath, new ProcessSettings { Arguments = arguments }); + if(result != 0) + { + // We should not recover from this. + throw new InvalidOperationException("Signing failed!"); + } + } + } +} From 12a263c1cb5d2277a3d1b0a490a5aa995c4d2564 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Mon, 6 Jul 2020 22:23:25 +0200 Subject: [PATCH 45/48] (GH-75) Template PackAsTool & nuspec->csproj --- build/Lifetime.cs | 4 - build/Tasks/PackageTemplate.cs | 21 +-- build/Utilities/ToolInstaller.cs | 79 ------------ template/Cake.Frosting.Template.csproj | 34 +++++ template/Cake.Frosting.Template.nuspec | 31 ----- template/build.ps1 | 120 ------------------ .../.template.config/template.json | 0 .../cakefrosting/build}/Build.csproj | 9 +- .../cakefrosting/build}/Context.cs | 0 .../cakefrosting/build}/Lifetime.cs | 0 .../cakefrosting/build}/Program.cs | 0 .../cakefrosting/build}/Tasks/Default.cs | 0 .../cakefrosting/build}/Tasks/Hello.cs | 0 13 files changed, 51 insertions(+), 247 deletions(-) create mode 100644 template/Cake.Frosting.Template.csproj delete mode 100644 template/Cake.Frosting.Template.nuspec delete mode 100644 template/build.ps1 rename template/{ => templates/cakefrosting}/.template.config/template.json (100%) rename template/{ => templates/cakefrosting/build}/Build.csproj (64%) rename template/{ => templates/cakefrosting/build}/Context.cs (100%) rename template/{ => templates/cakefrosting/build}/Lifetime.cs (100%) rename template/{ => templates/cakefrosting/build}/Program.cs (100%) rename template/{ => templates/cakefrosting/build}/Tasks/Default.cs (100%) rename template/{ => templates/cakefrosting/build}/Tasks/Hello.cs (100%) diff --git a/build/Lifetime.cs b/build/Lifetime.cs index 10b9352..a98dc50 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -38,10 +38,6 @@ public override void Setup(Context context) context.IsPrimaryBranch = StringComparer.OrdinalIgnoreCase.Equals(context.PrimaryBranchName, buildSystem.AppVeyor.Environment.Repository.Branch); context.BuildSystem = buildSystem; - // Install tools - context.Information("Installing tools..."); - context.InstallNuGetExe("5.6.0"); - // Install Global .Net Tools context.Information("Installing .Net Global Tools..."); context.DotNetCoreToolInstall("GitReleaseManager.Tool", "0.11.0", "dotnet-gitreleasemanager"); diff --git a/build/Tasks/PackageTemplate.cs b/build/Tasks/PackageTemplate.cs index 6ca53d8..1eaf169 100644 --- a/build/Tasks/PackageTemplate.cs +++ b/build/Tasks/PackageTemplate.cs @@ -1,7 +1,8 @@ -using System.Collections.Generic; -using Cake.Common.Tools.NuGet; -using Cake.Common.Tools.NuGet.Pack; +using Cake.Common.Tools.DotNetCore; +using Cake.Common.Tools.DotNetCore.MSBuild; +using Cake.Common.Tools.DotNetCore.Pack; using Cake.Common.Xml; +using Cake.Core.IO; using Cake.Frosting; public class PackageTemplate : FrostingTask @@ -11,17 +12,19 @@ public override void Run(Context context) if (context.AppVeyor) { context.XmlPoke( - "./template/Build.csproj", + "./template/templates/cakefrosting/build/Build.csproj", "/Project/ItemGroup/PackageReference[@Include = 'Cake.Frosting']/@Version", context.Version.SemVersion ); } - context.NuGetPack("./template/Cake.Frosting.Template.nuspec", new NuGetPackSettings + var path = new FilePath("./template/Cake.Frosting.Template.csproj"); + context.DotNetCorePack(path.FullPath, new DotNetCorePackSettings { - Version = context.Version.SemVersion, - OutputDirectory = context.Artifacts, - NoPackageAnalysis = true + Configuration = context.BuildConfiguration, + MSBuildSettings = new DotNetCoreMSBuildSettings() + .WithProperty("Version", context.Version.SemVersion), + OutputDirectory = context.Artifacts }); } -} \ No newline at end of file +} diff --git a/build/Utilities/ToolInstaller.cs b/build/Utilities/ToolInstaller.cs index b5e587a..e68364c 100644 --- a/build/Utilities/ToolInstaller.cs +++ b/build/Utilities/ToolInstaller.cs @@ -1,12 +1,6 @@ -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; -using Cake.Common.Tools.NuGet.Install; using Cake.Core; using Cake.Core.IO; @@ -14,79 +8,6 @@ public static class ToolInstaller { private static DirectoryPath ToolsPath { get; } = "./tools"; - 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, - ExcludeVersion = true, - OutputDirectory = ToolsPath - }); - } - public static FilePath DotNetCoreToolInstall( this ICakeContext context, string package, diff --git a/template/Cake.Frosting.Template.csproj b/template/Cake.Frosting.Template.csproj new file mode 100644 index 0000000..b9ed9c6 --- /dev/null +++ b/template/Cake.Frosting.Template.csproj @@ -0,0 +1,34 @@ + + + + Template + Cake.Frosting.Template + Cake.Frosting templates for the .NET SDK. + Cake.Frosting templates for the .NET SDK. + Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström and contributors + Copyright (c) .NET Foundation and contributors + Cake;Script;Build + cake-medium.png + MIT + git + https://github.com/cake-build/frosting + netcoreapp3.1 + + true + false + content + NU5110;NU5111;NU5128 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/template/Cake.Frosting.Template.nuspec b/template/Cake.Frosting.Template.nuspec deleted file mode 100644 index a5adb17..0000000 --- a/template/Cake.Frosting.Template.nuspec +++ /dev/null @@ -1,31 +0,0 @@ - - - - Cake.Frosting.Template - Cake.Frosting templates for the .NET SDK. - Cake (C# Make) is a build automation system with a C# DSL to do things like compiling code, copy files/folders, running unit tests, compress files and build NuGet packages. - Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström and contributors - MIT - https://github.com/cake-build/frosting - cake-medium.png - https://raw.githubusercontent.com/cake-build/graphics/master/png/cake-medium.png - false - Copyright (c) .NET Foundation and contributors - Cake Script Build - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/template/build.ps1 b/template/build.ps1 deleted file mode 100644 index 8bd24ea..0000000 --- a/template/build.ps1 +++ /dev/null @@ -1,120 +0,0 @@ -<# -.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 -) - -$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 -$ToolPath = Join-Path $PSScriptRoot "tools" -if (!(Test-Path $ToolPath)) { - Write-Verbose "Creating tools directory..." - New-Item -Path $ToolPath -Type directory | out-null -} - -########################################################################### -# INSTALL .NET CORE CLI -########################################################################### - -Function Remove-PathVariable([string]$VariableToRemove) -{ - $path = [Environment]::GetEnvironmentVariable("PATH", "User") - $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } - [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User") - $path = [Environment]::GetEnvironmentVariable("PATH", "Process") - $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } - [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process") -} - -# Get .NET Core CLI path if installed. -$FoundDotNetCliVersion = $null; -if (Get-Command dotnet -ErrorAction SilentlyContinue) { - $FoundDotNetCliVersion = dotnet --version; -} - -if($FoundDotNetCliVersion -ne $DotNetVersion) { - $InstallPath = Join-Path $PSScriptRoot ".dotnet" - if (!(Test-Path $InstallPath)) { - mkdir -Force $InstallPath | Out-Null; - } - (New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1"); - & $InstallPath\dotnet-install.ps1 -Version $DotNetVersion -InstallDir $InstallPath; - - Remove-PathVariable "$InstallPath" - $env:PATH = "$InstallPath;$env:PATH" - $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 - $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 -########################################################################### - -# Build the argument list. -$Arguments = @{ - target=$Target; - configuration=$Configuration; - verbosity=$Verbosity; - dryrun=$WhatIf; -}.GetEnumerator() | ForEach-Object { "--{0}=`"{1}`"" -f $_.key, $_.value }; - -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" - } - } -} -finally { - Pop-Location - exit $LASTEXITCODE; -} diff --git a/template/.template.config/template.json b/template/templates/cakefrosting/.template.config/template.json similarity index 100% rename from template/.template.config/template.json rename to template/templates/cakefrosting/.template.config/template.json diff --git a/template/Build.csproj b/template/templates/cakefrosting/build/Build.csproj similarity index 64% rename from template/Build.csproj rename to template/templates/cakefrosting/build/Build.csproj index 04460f5..9a16e83 100644 --- a/template/Build.csproj +++ b/template/templates/cakefrosting/build/Build.csproj @@ -2,14 +2,15 @@ Exe - netcoreapp3.0 - - + netcoreapp3.1 + true + + $(MSBuildProjectDirectory) - + diff --git a/template/Context.cs b/template/templates/cakefrosting/build/Context.cs similarity index 100% rename from template/Context.cs rename to template/templates/cakefrosting/build/Context.cs diff --git a/template/Lifetime.cs b/template/templates/cakefrosting/build/Lifetime.cs similarity index 100% rename from template/Lifetime.cs rename to template/templates/cakefrosting/build/Lifetime.cs diff --git a/template/Program.cs b/template/templates/cakefrosting/build/Program.cs similarity index 100% rename from template/Program.cs rename to template/templates/cakefrosting/build/Program.cs diff --git a/template/Tasks/Default.cs b/template/templates/cakefrosting/build/Tasks/Default.cs similarity index 100% rename from template/Tasks/Default.cs rename to template/templates/cakefrosting/build/Tasks/Default.cs diff --git a/template/Tasks/Hello.cs b/template/templates/cakefrosting/build/Tasks/Hello.cs similarity index 100% rename from template/Tasks/Hello.cs rename to template/templates/cakefrosting/build/Tasks/Hello.cs From 6ab42a5250f70d64b1d66078b400b1fb4c9e4146 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Wed, 8 Jul 2020 02:10:02 +0200 Subject: [PATCH 46/48] Move common MSBuild properties to Shared.msbuild --- .../Cake.Frosting.Example.csproj | 22 ++-------- .../Cake.Frosting.Tests.csproj | 16 +------ src/Cake.Frosting/Cake.Frosting.csproj | 29 ++---------- src/Shared.msbuild | 44 +++++++++++++++++++ template/Cake.Frosting.Template.csproj | 16 ++----- 5 files changed, 56 insertions(+), 71 deletions(-) create mode 100644 src/Shared.msbuild diff --git a/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj b/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj index ae9f85e..0f4f821 100644 --- a/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj +++ b/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj @@ -1,30 +1,16 @@  - Copyright (c) .NET Foundation and contributors - Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström and contributors - Cake;Build;Build automation - https://raw.githubusercontent.com/cake-build/graphics/master/png/cake-medium.png - https://github.com/cake-build/frosting/blob/develop/LICENSE - git - https://github.com/cake-build/frosting - 0.1.0 net461;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0 Cake.Frosting.Example Exe - Cake.Frosting.Example - false - false - false 7 - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb true - true + + + - - - - + diff --git a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj index 0ca0daf..ad8e77e 100644 --- a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj +++ b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj @@ -1,24 +1,11 @@ - Copyright (c) .NET Foundation and contributors - Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström and contributors - Cake;Build;Build automation - https://raw.githubusercontent.com/cake-build/graphics/master/png/cake-medium.png - https://github.com/cake-build/frosting/blob/develop/LICENSE - git - https://github.com/cake-build/frosting net461;netcoreapp2.1;netcoreapp3.0 7 - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - true - true - - $(DefineConstants);NETCORE - portable - + @@ -36,7 +23,6 @@ - diff --git a/src/Cake.Frosting/Cake.Frosting.csproj b/src/Cake.Frosting/Cake.Frosting.csproj index 7669999..fc6583e 100644 --- a/src/Cake.Frosting/Cake.Frosting.csproj +++ b/src/Cake.Frosting/Cake.Frosting.csproj @@ -1,41 +1,18 @@  - Cake.Frosting The .NET Core host for Cake. - Copyright (c) .NET Foundation and contributors - Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström and contributors - Cake;Build;Build automation - cake-medium.png - MIT - git - https://github.com/cake-build/frosting - 0.1.0 net461;netstandard2.0 true Cake.Frosting - false - false - false 7.2 - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - true - true - - - $(DefineConstants);NETCORE - portable + + - - - - - - - + true diff --git a/src/Shared.msbuild b/src/Shared.msbuild new file mode 100644 index 0000000..3a9a847 --- /dev/null +++ b/src/Shared.msbuild @@ -0,0 +1,44 @@ + + + 0.1.0 + $(AssemblyName) + Copyright (c) .NET Foundation and contributors + Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström, Dave Glick, Pascal Berger, Jérémie Desautels, Enrico Campidoglio and contributors + Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström, Dave Glick, Pascal Berger, Jérémie Desautels, Enrico Campidoglio and contributors + MIT + cake-medium.png + https://raw.githubusercontent.com/cake-build/graphics/master/png/cake-medium.png + Cake;Script;Build + https://cakebuild.net + https://github.com/cake-build/frosting.git + git + false + false + false + true + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + true + + + + $(DefineConstants);NETCORE + portable + + + + ../ + ../../ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/template/Cake.Frosting.Template.csproj b/template/Cake.Frosting.Template.csproj index b9ed9c6..d8d0fa1 100644 --- a/template/Cake.Frosting.Template.csproj +++ b/template/Cake.Frosting.Template.csproj @@ -2,16 +2,9 @@ Template - Cake.Frosting.Template + Cake.Frosting.Template Cake.Frosting templates for the .NET SDK. Cake.Frosting templates for the .NET SDK. - Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström and contributors - Copyright (c) .NET Foundation and contributors - Cake;Script;Build - cake-medium.png - MIT - git - https://github.com/cake-build/frosting netcoreapp3.1 true @@ -20,15 +13,14 @@ NU5110;NU5111;NU5128 + + - - - - + \ No newline at end of file From ff28f86398b0431c17fe1b9c302d78a9bbd2027d Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Wed, 15 Jul 2020 12:02:52 +0200 Subject: [PATCH 47/48] (GH-77) Update SDK/Framework/Studio versions * fixes #77 --- README.md | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 88abdf7..0788e1a 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,7 @@ [![NuGet](https://img.shields.io/nuget/v/Cake.Frosting.svg)](https://www.nuget.org/packages/Cake.Frosting) [![Azure Artifacts](https://azpkgsshield.azurevoodoo.net/cake-build/Cake/cake/cake.frosting)](https://dev.azure.com/cake-build/Cake/_packaging?_a=package&feed=cake&package=Cake.Frosting&protocolType=NuGet) A .NET Core host for Cake, that allows you to write your build scripts as a -(portable) console application (`netcoreapp2.0` or `net461`). Frosting is currently -in pre-release / incubation. - -**Expect things to move around initially. Especially naming of things.** +(portable) console application (`netcoreapp3.1` or `net461`). ## Table of Contents @@ -19,7 +16,7 @@ in pre-release / incubation. ## Example -### 1. Install .NET Core SDK 2.1.500 or later +### 1. Install .NET Core SDK 3.1.301 or later You can find the SDK at [https://dotnet.microsoft.com/download](https://dotnet.microsoft.com/download). @@ -54,12 +51,12 @@ The above command is what you're expected to run from your bootstrapper. ### .NET Core SDK To build from source, you will need to have -[.NET Core SDK 2.1.4](https://dotnet.microsoft.com/download) +[.NET Core SDK 3.1.301](https://dotnet.microsoft.com/download) installed on your machine. -### Visual Studio 2017 (optional) +### Visual Studio 2019 (optional) -If you want to develop using Visual Studio, then you need to use Visual Studio 2017 (15.2) or higher. +If you want to develop using Visual Studio, then you need to use Visual Studio 2019 (16.6) or higher. ## Acknowledgement @@ -79,11 +76,6 @@ each of the Cake developers with an [Open Source License](https://www.jetbrains.com/support/community/#section=open-source) for [ReSharper](https://www.jetbrains.com/resharper/) that helps with the development of Cake. -The Cake Team would also like to say thank you to the guys at -[MyGet](https://www.myget.org/) for their support in providing a Professional -subscription which allows us to continue to push all of our pre-release -editions of Cake NuGet packages for early consumption by the Cake community. - ## Code of Conduct This project has adopted the code of conduct defined by the From 142465229878b66ff0624ddbda5defbe01e4b7a5 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Wed, 15 Jul 2020 12:06:46 +0200 Subject: [PATCH 48/48] (GH-77) Add build badges * fixes #77 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0788e1a..277d329 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Frosting -[![NuGet](https://img.shields.io/nuget/v/Cake.Frosting.svg)](https://www.nuget.org/packages/Cake.Frosting) [![Azure Artifacts](https://azpkgsshield.azurevoodoo.net/cake-build/Cake/cake/cake.frosting)](https://dev.azure.com/cake-build/Cake/_packaging?_a=package&feed=cake&package=Cake.Frosting&protocolType=NuGet) +[![NuGet](https://img.shields.io/nuget/v/Cake.Frosting.svg)](https://www.nuget.org/packages/Cake.Frosting) [![Azure Artifacts](https://azpkgsshield.azurevoodoo.net/cake-build/Cake/cake/cake.frosting)](https://dev.azure.com/cake-build/Cake/_packaging?_a=package&feed=cake&package=Cake.Frosting&protocolType=NuGet) ![Build](https://github.com/cake-build/frosting/workflows/Build/badge.svg?branch=develop) [![Build status](https://ci.appveyor.com/api/projects/status/hb62doomg0mgc0fx/branch/develop?svg=true)](https://ci.appveyor.com/project/cakebuild/frosting/branch/develop) A .NET Core host for Cake, that allows you to write your build scripts as a (portable) console application (`netcoreapp3.1` or `net461`).