From ac0280e9c2abd1936dca707031b6449a16e5439a Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Tue, 8 Oct 2019 13:42:17 +0300 Subject: [PATCH 1/5] minor --- src/GitVersionVsixTask/GitVersion.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GitVersionVsixTask/GitVersion.ts b/src/GitVersionVsixTask/GitVersion.ts index 2089c6a6be..f0eb330b12 100644 --- a/src/GitVersionVsixTask/GitVersion.ts +++ b/src/GitVersionVsixTask/GitVersion.ts @@ -98,7 +98,7 @@ export class GitVersionTask { } } - async installTool(version: string, includePrerelease: boolean) : Promise { + async installTool(version: string, includePrerelease: boolean): Promise { let installTool = tl.getVariable("INSTALL_TOOL"); if (installTool === null || installTool === undefined || installTool.toUpperCase() == "TRUE") { return await new ToolInstaller().downloadAndInstall("GitVersion.Tool", version, false, includePrerelease); @@ -108,7 +108,7 @@ export class GitVersionTask { getWorkingDirectory(targetPath: string) { let workDir; - if (!targetPath){ + if (!targetPath) { workDir = this.sourcesDirectory; } else { if (tl.exist(targetPath) && tl.stats(targetPath).isDirectory()) { From d00e07a39df0a580e157db1f701d2de7f8d35b85 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Thu, 3 Oct 2019 18:07:26 +0300 Subject: [PATCH 2/5] made the GitversionCore netstandard only --- src/Directory.Build.props | 1 + src/GitVersionCore.Tests/GitVersionCore.Tests.csproj | 3 ++- src/GitVersionCore/GitVersionCore.csproj | 2 +- src/GitVersionExe/GitVersionExe.csproj | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index fe71a61e0d..383118f2f4 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -15,6 +15,7 @@ 0.26.1 + 2.0.289 2019.1.3 7.0.0 12.0.2 diff --git a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj index e0c6806ded..3b95800a26 100644 --- a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -1,4 +1,4 @@ - + net472;netcoreapp2.1 @@ -12,6 +12,7 @@ + diff --git a/src/GitVersionCore/GitVersionCore.csproj b/src/GitVersionCore/GitVersionCore.csproj index 4832b2d8c3..9348e172bb 100644 --- a/src/GitVersionCore/GitVersionCore.csproj +++ b/src/GitVersionCore/GitVersionCore.csproj @@ -1,7 +1,7 @@  - net472;netstandard2.0 + netstandard2.0 GitVersion false bin\$(Configuration)\GitVersionCore.xml diff --git a/src/GitVersionExe/GitVersionExe.csproj b/src/GitVersionExe/GitVersionExe.csproj index 689fc02058..271840b51c 100644 --- a/src/GitVersionExe/GitVersionExe.csproj +++ b/src/GitVersionExe/GitVersionExe.csproj @@ -1,4 +1,4 @@ - + Exe @@ -24,6 +24,7 @@ + From 9181ea0c7bc57d67578518692ffa1aa07b6cfae5 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Tue, 24 Sep 2019 21:35:34 +0300 Subject: [PATCH 3/5] (build) add net core 3.0 --- build.config | 2 +- build/stages/common-steps.yml | 10 +++++++--- src/Docker/docker.json | 8 ++++---- src/GitVersionCore.Tests/GitVersionCore.Tests.csproj | 2 +- src/GitVersionExe.Tests/GitVersionExe.Tests.csproj | 2 +- src/GitVersionExe/GitVersionExe.csproj | 2 +- .../GitVersionTask.MsBuild.csproj | 2 +- src/GitVersionTask.Tests/GitVersionTask.Tests.csproj | 2 +- src/GitVersionTask/GitVersionTask.csproj | 2 +- 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/build.config b/build.config index 0bdbde330e..e7caa0cb0e 100644 --- a/build.config +++ b/build.config @@ -1,3 +1,3 @@ #!/usr/bin/env bash CAKE_VERSION=0.35 -DOTNET_VERSION=2.2.401 +DOTNET_VERSION=2.1.802,3.0.100 diff --git a/build/stages/common-steps.yml b/build/stages/common-steps.yml index ff2be8dbd8..3f093d6007 100644 --- a/build/stages/common-steps.yml +++ b/build/stages/common-steps.yml @@ -1,10 +1,14 @@ steps: - task: UseDotNet@2 - displayName: 'Use .NET Core sdk' + displayName: 'Use .NET Core sdk 2.1' inputs: packageType: sdk - version: 2.2.401 - installationPath: $(Agent.ToolsDirectory)/dotnet + version: 2.1.802 +- task: UseDotNet@2 + displayName: 'Use .NET Core sdk 3.0' + inputs: + packageType: sdk + version: 3.0.100 - task: Bash@3 displayName: 'Env Vars' inputs: diff --git a/src/Docker/docker.json b/src/Docker/docker.json index b57cd00fe0..fb602654a8 100644 --- a/src/Docker/docker.json +++ b/src/Docker/docker.json @@ -3,14 +3,14 @@ "2.1": [ "centos-7", "debian-9", - "fedora-28", + "fedora-30", "ubuntu-16.04", "ubuntu-18.04" ], - "2.2": [ + "3.0": [ "centos-7", "debian-9", - "fedora-28", + "fedora-30", "ubuntu-16.04", "ubuntu-18.04" ] @@ -19,7 +19,7 @@ "2.1": [ "nanoserver-1809" ], - "2.2": [ + "3.0": [ "nanoserver-1809" ] } diff --git a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj index 3b95800a26..f81f41ec9a 100644 --- a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp2.1 + net472;netcoreapp2.1;netcoreapp3.0 full false diff --git a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj index 9e1789c8b8..7ca2265ca2 100644 --- a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj +++ b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj @@ -1,6 +1,6 @@ - net472;netcoreapp2.1 + net472;netcoreapp2.1;netcoreapp3.0 diff --git a/src/GitVersionExe/GitVersionExe.csproj b/src/GitVersionExe/GitVersionExe.csproj index 271840b51c..a573c3d5f4 100644 --- a/src/GitVersionExe/GitVersionExe.csproj +++ b/src/GitVersionExe/GitVersionExe.csproj @@ -4,7 +4,7 @@ Exe GitVersion GitVersion - netcoreapp2.1 + netcoreapp2.1;netcoreapp3.0 false AnyCPU MIT diff --git a/src/GitVersionTask.MsBuild/GitVersionTask.MsBuild.csproj b/src/GitVersionTask.MsBuild/GitVersionTask.MsBuild.csproj index dbb12bf07b..0f6144b29e 100644 --- a/src/GitVersionTask.MsBuild/GitVersionTask.MsBuild.csproj +++ b/src/GitVersionTask.MsBuild/GitVersionTask.MsBuild.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp2.1 + net472;netcoreapp2.1;netcoreapp3.0 diff --git a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj index a7547953fc..ecb598733f 100644 --- a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -1,6 +1,6 @@ - net472;netcoreapp2.1 + net472;netcoreapp2.1;netcoreapp3.0 diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index 3b094bffcf..400142994f 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp2.1 + net472;netcoreapp2.1;netcoreapp3.0 true From 487c0834152bbe9d589028480ac4056adf32aa42 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Wed, 9 Oct 2019 20:57:52 +0300 Subject: [PATCH 4/5] use NETFRAMEWORK constant instead of NET472 --- src/GitVersionExe.Tests/Helpers/PathHelper.cs | 4 ++-- .../LibGit2Sharp/GitLoaderContext.cs | 2 +- .../LibGit2Sharp/LibGit2SharpLoader.cs | 4 ++-- .../LibGit2Sharp/RuntimeIdMap.cs | 10 +++++----- src/GitVersionTask.MsBuild/TaskProxy.cs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/GitVersionExe.Tests/Helpers/PathHelper.cs b/src/GitVersionExe.Tests/Helpers/PathHelper.cs index 225ab3806f..49ecf47ceb 100644 --- a/src/GitVersionExe.Tests/Helpers/PathHelper.cs +++ b/src/GitVersionExe.Tests/Helpers/PathHelper.cs @@ -13,7 +13,7 @@ public static string GetCurrentDirectory() public static string GetExecutable() { -#if NET472 +#if NETFRAMEWORK var executable = Path.Combine(GetExeDirectory(), "GitVersion.exe"); #else var executable = "dotnet"; @@ -23,7 +23,7 @@ public static string GetExecutable() public static string GetExecutableArgs(string args) { -#if !NET472 +#if !NETFRAMEWORK args = $"{Path.Combine(GetExeDirectory(), "GitVersion.dll")} {args}"; #endif return args; diff --git a/src/GitVersionTask.MsBuild/LibGit2Sharp/GitLoaderContext.cs b/src/GitVersionTask.MsBuild/LibGit2Sharp/GitLoaderContext.cs index c9e0a85afe..0922a33d9b 100644 --- a/src/GitVersionTask.MsBuild/LibGit2Sharp/GitLoaderContext.cs +++ b/src/GitVersionTask.MsBuild/LibGit2Sharp/GitLoaderContext.cs @@ -1,5 +1,5 @@ // This code originally copied from https://raw.githubusercontent.com/dotnet/sourcelink/master/src/Microsoft.Build.Tasks.Git/GitLoaderContext.cs -#if !NET472 +#if !NETFRAMEWORK using System; using System.IO; using System.Linq; diff --git a/src/GitVersionTask.MsBuild/LibGit2Sharp/LibGit2SharpLoader.cs b/src/GitVersionTask.MsBuild/LibGit2Sharp/LibGit2SharpLoader.cs index 92c63d7757..6fd3989420 100644 --- a/src/GitVersionTask.MsBuild/LibGit2Sharp/LibGit2SharpLoader.cs +++ b/src/GitVersionTask.MsBuild/LibGit2Sharp/LibGit2SharpLoader.cs @@ -19,7 +19,7 @@ public class LibGit2SharpLoader private LibGit2SharpLoader(string tasksAssembly) { taskDirectory = Path.GetDirectoryName(typeof(LibGit2SharpLoader).Assembly.Location); -#if NET472 +#if NETFRAMEWORK nullVersion = new Version(0, 0, 0, 0); loaderLog = new List(); @@ -34,7 +34,7 @@ private LibGit2SharpLoader(string tasksAssembly) #endif } -#if NET472 +#if NETFRAMEWORK private static Version nullVersion; diff --git a/src/GitVersionTask.MsBuild/LibGit2Sharp/RuntimeIdMap.cs b/src/GitVersionTask.MsBuild/LibGit2Sharp/RuntimeIdMap.cs index 90bf777324..90b3fdefa9 100644 --- a/src/GitVersionTask.MsBuild/LibGit2Sharp/RuntimeIdMap.cs +++ b/src/GitVersionTask.MsBuild/LibGit2Sharp/RuntimeIdMap.cs @@ -1,5 +1,5 @@ // This code originally copied from https://raw.githubusercontent.com/dotnet/sourcelink/master/src/Microsoft.Build.Tasks.Git/RuntimeIdMap.cs -#if !NET472 +#if !NETFRAMEWORK using System; using System.Diagnostics; @@ -48,14 +48,14 @@ void FindBestCandidate(int startIndex, int increment) // Find the highest available version that is lower than or equal to the runtime version // among candidates that have the same qualifiers. - if (candidateQualifiers == runtimeQualifiers && - CompareVersions(candidateVersion, runtimeVersion) <= 0 && + if (candidateQualifiers == runtimeQualifiers && + CompareVersions(candidateVersion, runtimeVersion) <= 0 && (bestVersion == null || CompareVersions(candidateVersion, bestVersion) > 0)) { bestMatchIndex = i; bestVersion = candidateVersion; } - + i += increment; } } @@ -105,7 +105,7 @@ internal static int CompareVersions(string[] left, string[] right) internal static void ParseRuntimeId(string runtimeId, out string osName, out string[] version, out string qualifiers) { - // We use the following convention in all newly-defined RIDs. Some RIDs (win7-x64, win8-x64) predate this convention and don't follow it, but all new RIDs should follow it. + // We use the following convention in all newly-defined RIDs. Some RIDs (win7-x64, win8-x64) predate this convention and don't follow it, but all new RIDs should follow it. // [os name].[version]-[architecture]-[additional qualifiers] // See https://github.com/dotnet/corefx/blob/master/pkg/Microsoft.NETCore.Platforms/readme.md#naming-convention diff --git a/src/GitVersionTask.MsBuild/TaskProxy.cs b/src/GitVersionTask.MsBuild/TaskProxy.cs index 793e2ddc89..20bbc15005 100644 --- a/src/GitVersionTask.MsBuild/TaskProxy.cs +++ b/src/GitVersionTask.MsBuild/TaskProxy.cs @@ -14,7 +14,7 @@ public static class TaskProxy static TaskProxy() { -#if !NET472 +#if !NETFRAMEWORK GitLoaderContext.Init("GitVersionCore", "LibGit2Sharp"); #endif LibGit2SharpLoader.LoadAssembly("GitVersionTask"); From 1d6a9da6ea3f379373dc67216b1919e678e14d76 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Wed, 9 Oct 2019 21:02:36 +0300 Subject: [PATCH 5/5] added support for .net core 3.0. Generate native executables for all os-es --- build.cake | 3 +- build/docker.cake | 2 +- build/pack.cake | 167 +++++++++++++++++++----------------- build/publish.cake | 8 +- build/utils/docker.cake | 9 +- build/utils/parameters.cake | 21 +++-- build/utils/paths.cake | 73 ++++++++-------- build/utils/utils.cake | 61 ------------- 8 files changed, 150 insertions(+), 194 deletions(-) diff --git a/build.cake b/build.cake index 96f599ad54..99c61b5086 100644 --- a/build.cake +++ b/build.cake @@ -3,6 +3,7 @@ // Install addins. #addin "nuget:?package=Cake.Codecov&version=0.7.0" +#addin "nuget:?package=Cake.Compression&version=0.2.4" #addin "nuget:?package=Cake.Coverlet&version=2.3.4" #addin "nuget:?package=Cake.Docker&version=0.10.1" #addin "nuget:?package=Cake.Gem&version=0.8.1" @@ -13,11 +14,11 @@ #addin "nuget:?package=Cake.Tfx&version=0.9.1" #addin "nuget:?package=Newtonsoft.Json&version=12.0.2" +#addin "nuget:?package=SharpZipLib&version=1.2.0" #addin "nuget:?package=xunit.assert&version=2.4.1" // Install tools. #tool "nuget:?package=NUnit.ConsoleRunner&version=3.10.0" -#tool "nuget:?package=ILRepack&version=2.0.18" #tool "nuget:?package=nuget.commandline&version=5.2.0" // Install .NET Core Global tools. diff --git a/build/docker.cake b/build/docker.cake index 93c43969d9..1ee760e4b3 100644 --- a/build/docker.cake +++ b/build/docker.cake @@ -3,7 +3,7 @@ singleStageRun = !IsEnabled(Context, "ENABLED_MULTI_STAGE_BUILD", false); Task("Docker-Build") .WithCriteria((context, parameters) => !parameters.IsRunningOnMacOS, "Docker can be built only on Windows or Linux agents.") .WithCriteria((context, parameters) => parameters.IsRunningOnAzurePipeline, "Docker-Build works only on AzurePipeline.") - .IsDependentOnWhen("Copy-Files", singleStageRun) + .IsDependentOnWhen("Pack-Prepare", singleStageRun) .Does((parameters) => { foreach(var dockerImage in parameters.Docker.Images) diff --git a/build/pack.cake b/build/pack.cake index 64ca279118..38d5f07a68 100644 --- a/build/pack.cake +++ b/build/pack.cake @@ -38,7 +38,7 @@ Task("Test") .IsDependentOn("Build") .Does((parameters) => { - var frameworks = new[] { parameters.CoreFxVersion21, parameters.FullFxVersion }; + var frameworks = new[] { parameters.CoreFxVersion21, parameters.CoreFxVersion30, parameters.FullFxVersion472 }; var testResultsPath = parameters.Paths.Directories.TestResultsOutput; foreach(var framework in frameworks) @@ -71,7 +71,7 @@ Task("Test") CoverletOutputName = $"{projectName}.coverage.xml" }; - if (IsRunningOnUnix() && string.Equals(framework, parameters.FullFxVersion)) + if (IsRunningOnUnix() && string.Equals(framework, parameters.FullFxVersion472)) { settings.Filter = "TestCategory!=NoMono"; } @@ -119,70 +119,83 @@ Task("Test") #endregion #region Pack - -Task("Copy-Files") +Task("Pack-Prepare") .IsDependentOn("Test") .Does((parameters) => { - // .NET Core - var coreFxDir = parameters.Paths.Directories.ArtifactsBinCoreFx21.Combine("tools"); - DotNetCorePublish("./src/GitVersionExe/GitVersionExe.csproj", new DotNetCorePublishSettings + // publish single file for all native runtimes (self contained) + foreach(var runtime in parameters.NativeRuntimes) { - Framework = parameters.CoreFxVersion21, - NoRestore = false, - Configuration = parameters.Configuration, - OutputDirectory = coreFxDir, - MSBuildSettings = parameters.MSBuildSettings - }); + var runtimeName = runtime.Value; - // Copy license & Copy GitVersion.XML (since publish does not do this anymore) - CopyFileToDirectory("./LICENSE", coreFxDir); - CopyFileToDirectory($"./src/GitVersionExe/bin/{parameters.Configuration}/{parameters.CoreFxVersion21}/GitVersion.xml", coreFxDir); + var settings = new DotNetCorePublishSettings + { + Framework = parameters.CoreFxVersion30, + Runtime = runtimeName, + NoRestore = false, + Configuration = parameters.Configuration, + OutputDirectory = parameters.Paths.Directories.Native.Combine(runtimeName), + MSBuildSettings = parameters.MSBuildSettings, + }; - // .NET Framework - DotNetCorePublish("./src/GitVersionExe/GitVersionExe.csproj", new DotNetCorePublishSettings - { - Framework = parameters.FullFxVersion, - NoBuild = true, - NoRestore = false, - Configuration = parameters.Configuration, - OutputDirectory = parameters.Paths.Directories.ArtifactsBinFullFx, - MSBuildSettings = parameters.MSBuildSettings - }); + settings.ArgumentCustomization = + arg => arg + .Append("/p:PublishSingleFile=true") + .Append("/p:PublishTrimmed=true") + .Append("/p:IncludeSymbolsInSingleFile=true"); + + DotNetCorePublish("./src/GitVersionExe/GitVersionExe.csproj", settings); + } + + var frameworks = new[] { parameters.CoreFxVersion21, parameters.CoreFxVersion30, parameters.FullFxVersion472 }; - DotNetCorePublish("./src/GitVersionTask/GitVersionTask.csproj", new DotNetCorePublishSettings + // publish Framework-dependent deployment + foreach(var framework in frameworks) { - Framework = parameters.FullFxVersion, - NoBuild = true, - NoRestore = true, - Configuration = parameters.Configuration, - MSBuildSettings = parameters.MSBuildSettings - }); + var settings = new DotNetCorePublishSettings + { + Framework = framework, + NoRestore = false, + Configuration = parameters.Configuration, + OutputDirectory = parameters.Paths.Directories.ArtifactsBin.Combine(framework), + MSBuildSettings = parameters.MSBuildSettings, + }; + + DotNetCorePublish("./src/GitVersionExe/GitVersionExe.csproj", settings); + } + + frameworks = new[] { parameters.CoreFxVersion21, parameters.FullFxVersion472 }; - // .NET Core - DotNetCorePublish("./src/GitVersionTask/GitVersionTask.csproj", new DotNetCorePublishSettings + // MsBuild Task + foreach(var framework in frameworks) { - Framework = parameters.CoreFxVersion21, - NoBuild = true, - NoRestore = true, - Configuration = parameters.Configuration, - MSBuildSettings = parameters.MSBuildSettings - }); - var ilMergeDir = parameters.Paths.Directories.ArtifactsBinFullFxILMerge; - var portableDir = parameters.Paths.Directories.ArtifactsBinFullFxPortable.Combine("tools"); - var cmdlineDir = parameters.Paths.Directories.ArtifactsBinFullFxCmdline.Combine("tools"); - - // Portable - PublishILRepackedGitVersionExe(true, ilMergeDir, portableDir, parameters); - // Commandline - PublishILRepackedGitVersionExe(false, ilMergeDir, cmdlineDir, parameters); - - // Ruby Gem - var gemPath = new DirectoryPath("./src/GitVersionRubyGem/bin"); - EnsureDirectoryExists(gemPath); - CopyFileToDirectory(portableDir + "/" + "LibGit2Sharp.dll.config", gemPath); - CopyFileToDirectory(portableDir + "/" + "GitVersion.exe", gemPath); - CopyDirectory(portableDir.Combine("lib"), gemPath.Combine("lib")); + DotNetCorePublish("./src/GitVersionTask/GitVersionTask.csproj", new DotNetCorePublishSettings + { + Framework = framework, + Configuration = parameters.Configuration, + MSBuildSettings = parameters.MSBuildSettings + }); + } + + var sourceDir = parameters.Paths.Directories.Native.Combine(parameters.NativeRuntimes[PlatformFamily.Windows]); + var sourceFiles = GetFiles(sourceDir + "/*.*"); + + // RubyGem + var gemDir = new DirectoryPath("./src/GitVersionRubyGem/bin"); + EnsureDirectoryExists(gemDir); + CopyFiles(sourceFiles, gemDir); + + // Cmdline and Portable + var cmdlineDir = parameters.Paths.Directories.ArtifactsBinCmdline.Combine("tools"); + var portableDir = parameters.Paths.Directories.ArtifactsBinPortable.Combine("tools"); + + EnsureDirectoryExists(cmdlineDir); + EnsureDirectoryExists(portableDir); + + CopyFiles(sourceFiles, cmdlineDir); + + sourceFiles += GetFiles("./nuspec/*.ps1") + GetFiles("./nuspec/*.txt"); + CopyFiles(sourceFiles, portableDir); }); Task("Pack-Vsix") @@ -204,7 +217,6 @@ Task("Pack-Vsix") UpdateTaskVersion(new FilePath(workDir + "/GitVersionTask/task.json"), taskId, parameters.Version.GitVersion); // build and pack - var settings = new TfxExtensionCreateSettings { ToolPath = workDir + "/node_modules/.bin/" + (parameters.IsRunningOnWindows ? "tfx.cmd" : "tfx"), @@ -217,7 +229,7 @@ Task("Pack-Vsix") }); Task("Pack-Gem") - .IsDependentOn("Copy-Files") + .IsDependentOn("Pack-Prepare") .Does((parameters) => { var workDir = "./src/GitVersionRubyGem"; @@ -237,7 +249,7 @@ Task("Pack-Gem") }); Task("Pack-Nuget") - .IsDependentOn("Copy-Files") + .IsDependentOn("Pack-Prepare") .Does((parameters) => { foreach(var package in parameters.Packages.Nuget) @@ -263,8 +275,6 @@ Task("Pack-Nuget") { Configuration = parameters.Configuration, OutputDirectory = parameters.Paths.Directories.NugetRoot, - NoBuild = true, - NoRestore = true, MSBuildSettings = parameters.MSBuildSettings }; @@ -278,7 +288,7 @@ Task("Pack-Nuget") Task("Pack-Chocolatey") .WithCriteria((context, parameters) => parameters.IsRunningOnWindows, "Pack-Chocolatey works only on Windows agents.") .WithCriteria((context, parameters) => parameters.IsMainBranch, "Pack-Chocolatey works only for main branch.") - .IsDependentOn("Copy-Files") + .IsDependentOn("Pack-Prepare") .Does((parameters) => { foreach(var package in parameters.Packages.Chocolatey) @@ -286,33 +296,30 @@ Task("Pack-Chocolatey") if (FileExists(package.NuspecPath)) { var artifactPath = MakeAbsolute(parameters.PackagesBuildMap[package.Id]).FullPath; - var files = GetFiles(artifactPath + "/**/*.*") - .Select(file => new ChocolateyNuSpecContent { Source = file.FullPath, Target = file.FullPath.Replace(artifactPath, "") }); - var txtFiles = (GetFiles("./nuspec/*.txt") + GetFiles("./nuspec/*.ps1")) - .Select(file => new ChocolateyNuSpecContent { Source = file.FullPath, Target = file.GetFilename().ToString() }); - - ChocolateyPack(package.NuspecPath, new ChocolateyPackSettings { + var chocolateySettings = new ChocolateyPackSettings + { Verbose = true, Version = parameters.Version.SemVersion, OutputDirectory = parameters.Paths.Directories.NugetRoot, - Files = files.Concat(txtFiles).ToArray() - }); + Files = GetFiles(artifactPath + "/**/*.*") + .Select(file => new ChocolateyNuSpecContent { Source = file.FullPath, Target = file.FullPath.Replace(artifactPath, "") }) + .ToArray() + }; + ChocolateyPack(package.NuspecPath, chocolateySettings); } } }); Task("Zip-Files") - .IsDependentOn("Copy-Files") + .IsDependentOn("Pack-Prepare") .Does((parameters) => { - // .NET Framework - var cmdlineDir = parameters.Paths.Directories.ArtifactsBinFullFxCmdline.Combine("tools"); - var fullFxFiles = GetFiles(cmdlineDir.FullPath + "/**/*"); - Zip(cmdlineDir, parameters.Paths.Files.ZipArtifactPathDesktop, fullFxFiles); - - // .NET Core - var coreFxDir = parameters.Paths.Directories.ArtifactsBinCoreFx21.Combine("tools"); - var coreclrFiles = GetFiles(coreFxDir.FullPath + "/**/*"); - Zip(coreFxDir, parameters.Paths.Files.ZipArtifactPathCoreClr, coreclrFiles); + foreach(var runtime in parameters.NativeRuntimes) + { + var sourceDir = parameters.Paths.Directories.Native.Combine(runtime.Value); + var fileName = $"gitversion-{runtime.Key}-{parameters.Version.SemVersion}.tar.gz".ToLower(); + var tarFile = parameters.Paths.Directories.Artifacts.CombineWithFilePath(fileName); + GZipCompress(sourceDir, tarFile); + } }); #endregion diff --git a/build/publish.cake b/build/publish.cake index 4a86957409..392e9221c4 100644 --- a/build/publish.cake +++ b/build/publish.cake @@ -22,8 +22,12 @@ Task("Release-Notes") TargetCommitish = "master" }); - GitReleaseManagerAddAssets(token, repoOwner, repository, parameters.Version.Milestone, parameters.Paths.Files.ZipArtifactPathDesktop.ToString()); - GitReleaseManagerAddAssets(token, repoOwner, repository, parameters.Version.Milestone, parameters.Paths.Files.ZipArtifactPathCoreClr.ToString()); + var zipFiles = GetFiles(parameters.Paths.Directories.Artifacts + "/*.tar.gz"); + foreach(var zipFile in zipFiles) + { + GitReleaseManagerAddAssets(token, repoOwner, repository, parameters.Version.Milestone, zipFile.ToString()); + } + GitReleaseManagerClose(token, repoOwner, repository, parameters.Version.Milestone); }).ReportError(exception => diff --git a/build/utils/docker.cake b/build/utils/docker.cake index f166900109..d8a4c9e087 100644 --- a/build/utils/docker.cake +++ b/build/utils/docker.cake @@ -28,9 +28,7 @@ void DockerBuild(DockerImage dockerImage, BuildParameters parameters) var (os, distro, targetframework) = dockerImage; var workDir = DirectoryPath.FromString($"./src/Docker"); - var sourceDir = targetframework.StartsWith("netcoreapp") - ? parameters.Paths.Directories.ArtifactsBinCoreFx21.Combine("tools") - : parameters.Paths.Directories.ArtifactsBinFullFxCmdline.Combine("tools"); + var sourceDir = parameters.Paths.Directories.ArtifactsBin.Combine(targetframework); CopyDirectory(sourceDir, workDir.Combine("content")); @@ -102,6 +100,11 @@ void DockerTestArtifact(DockerImage dockerImage, BuildParameters parameters, str Information("Docker tag: {0}", tag); Information("Docker cmd: {0}", cmd); + if (os == "windows" && targetframework == parameters.CoreFxVersion30) + { + cmd = "-Command " + cmd; // powershell 7 needs a -Command parameter + } + DockerTestRun(settings, parameters, tag, "pwsh", cmd); } diff --git a/build/utils/parameters.cake b/build/utils/parameters.cake index 96f3838c86..5ddeeeb3fd 100644 --- a/build/utils/parameters.cake +++ b/build/utils/parameters.cake @@ -10,8 +10,9 @@ public class BuildParameters public const string MainRepoOwner = "gittools"; public const string MainRepoName = "GitVersion"; - public string CoreFxVersion21 { get; private set; } = "netcoreapp2.1"; - public string FullFxVersion { get; private set; } = "net472"; + public string CoreFxVersion21 { get; private set; } = "netcoreapp2.1"; + public string CoreFxVersion30 { get; private set; } = "netcoreapp3.0"; + public string FullFxVersion472 { get; private set; } = "net472"; public string DockerDistro { get; private set; } public string DockerDotnetVersion { get; private set; } @@ -51,6 +52,7 @@ public class BuildParameters public BuildArtifacts Artifacts { get; private set; } public DockerImages Docker { get; private set; } public Dictionary PackagesBuildMap { get; private set; } + public Dictionary NativeRuntimes { get; private set; } public bool IsStableRelease() => !IsLocalBuild && IsMainRepo && IsMainBranch && !IsPullRequest && IsTagged; public bool IsPreRelease() => !IsLocalBuild && IsMainRepo && IsMainBranch && !IsPullRequest && !IsTagged; @@ -125,17 +127,22 @@ public class BuildParameters var files = Paths.Files; - var buildArtifacts = context.GetFiles(Paths.Directories.BuildArtifact + "/*.*"); - buildArtifacts += files.ZipArtifactPathDesktop; - buildArtifacts += files.ZipArtifactPathCoreClr; + var buildArtifacts = context.GetFiles(Paths.Directories.BuildArtifact + "/*.*") + context.GetFiles(Paths.Directories.Artifacts + "/*.tar.gz"); buildArtifacts += files.ReleaseNotesOutputFilePath; Artifacts = BuildArtifacts.GetArtifacts(buildArtifacts.ToArray()); PackagesBuildMap = new Dictionary { - ["GitVersion.CommandLine"] = Paths.Directories.ArtifactsBinFullFxCmdline, - ["GitVersion.Portable"] = Paths.Directories.ArtifactsBinFullFxPortable, + ["GitVersion.CommandLine"] = Paths.Directories.ArtifactsBinCmdline, + ["GitVersion.Portable"] = Paths.Directories.ArtifactsBinPortable, + }; + + NativeRuntimes = new Dictionary + { + [PlatformFamily.Windows] = "win-x64", + [PlatformFamily.Linux] = "linux-x64", + [PlatformFamily.OSX] = "osx-x64", }; Credentials = BuildCredentials.GetCredentials(context); diff --git a/build/utils/paths.cake b/build/utils/paths.cake index 0627e26676..5fcaae0047 100644 --- a/build/utils/paths.cake +++ b/build/utils/paths.cake @@ -27,18 +27,16 @@ public class BuildPaths var artifactsDir = (DirectoryPath)(context.Directory("./artifacts") + context.Directory("v" + semVersion)); var artifactsBinDir = artifactsDir.Combine("bin"); - var artifactsBinFullFxDir = artifactsBinDir.Combine(parameters.FullFxVersion); - var artifactsBinFullFxILMergeDir = artifactsBinFullFxDir.Combine("il-merge"); - var artifactsBinFullFxPortableDir = artifactsBinFullFxDir.Combine("portable"); - var artifactsBinFullFxCmdlineDir = artifactsBinFullFxDir.Combine("cmdline"); - var artifactsBinCoreFxDir = artifactsBinDir.Combine(parameters.CoreFxVersion21); + var artifactsBinPortableDir = artifactsBinDir.Combine("portable"); + var artifactsBinCmdlineDir = artifactsBinDir.Combine("cmdline"); + var artifactsBinCoreFx21Dir = artifactsBinDir.Combine(parameters.CoreFxVersion21); + var artifactsBinCoreFx30Dir = artifactsBinDir.Combine(parameters.CoreFxVersion30); + var artifactsBinFullFx472Dir = artifactsBinDir.Combine(parameters.FullFxVersion472); + var nativeDir = artifactsDir.Combine("native"); var nugetRootDir = artifactsDir.Combine("nuget"); var buildArtifactDir = artifactsDir.Combine("build-artifact"); var testResultsOutputDir = artifactsDir.Combine("test-results"); - var zipArtifactPathCoreClr = artifactsDir.CombineWithFilePath("GitVersion-bin-corefx-v" + semVersion + ".zip"); - var zipArtifactPathDesktop = artifactsDir.CombineWithFilePath("GitVersion-bin-fullfx-v" + semVersion + ".zip"); - var releaseNotesOutputFilePath = buildArtifactDir.CombineWithFilePath("releasenotes.md"); var gemOutputFilePath = buildArtifactDir.CombineWithFilePath("gitversion-" + version.GemVersion + ".gem"); @@ -48,21 +46,20 @@ public class BuildPaths // Directories var buildDirectories = new BuildDirectories( artifactsDir, + nativeDir, buildArtifactDir, testResultsOutputDir, nugetRootDir, artifactsBinDir, - artifactsBinFullFxDir, - artifactsBinFullFxPortableDir, - artifactsBinFullFxCmdlineDir, - artifactsBinFullFxILMergeDir, - artifactsBinCoreFxDir); + artifactsBinPortableDir, + artifactsBinCmdlineDir, + artifactsBinCoreFx21Dir, + artifactsBinCoreFx30Dir, + artifactsBinFullFx472Dir); // Files var buildFiles = new BuildFiles( context, - zipArtifactPathCoreClr, - zipArtifactPathDesktop, releaseNotesOutputFilePath, vsixOutputFilePath, gemOutputFilePath); @@ -77,23 +74,17 @@ public class BuildPaths public class BuildFiles { - public FilePath ZipArtifactPathCoreClr { get; private set; } - public FilePath ZipArtifactPathDesktop { get; private set; } public FilePath ReleaseNotesOutputFilePath { get; private set; } public FilePath VsixOutputFilePath { get; private set; } public FilePath GemOutputFilePath { get; private set; } public BuildFiles( ICakeContext context, - FilePath zipArtifactPathCoreClr, - FilePath zipArtifactPathDesktop, FilePath releaseNotesOutputFilePath, FilePath vsixOutputFilePath, FilePath gemOutputFilePath ) { - ZipArtifactPathCoreClr = zipArtifactPathCoreClr; - ZipArtifactPathDesktop = zipArtifactPathDesktop; ReleaseNotesOutputFilePath = releaseNotesOutputFilePath; VsixOutputFilePath = vsixOutputFilePath; GemOutputFilePath = gemOutputFilePath; @@ -103,51 +94,55 @@ public class BuildFiles public class BuildDirectories { public DirectoryPath Artifacts { get; private set; } + public DirectoryPath Native { get; private set; } public DirectoryPath NugetRoot { get; private set; } public DirectoryPath BuildArtifact { get; private set; } public DirectoryPath TestResultsOutput { get; private set; } public DirectoryPath ArtifactsBin { get; private set; } - public DirectoryPath ArtifactsBinFullFx { get; private set; } - public DirectoryPath ArtifactsBinFullFxPortable { get; private set; } - public DirectoryPath ArtifactsBinFullFxCmdline { get; private set; } - public DirectoryPath ArtifactsBinFullFxILMerge { get; private set; } + public DirectoryPath ArtifactsBinPortable { get; private set; } + public DirectoryPath ArtifactsBinCmdline { get; private set; } public DirectoryPath ArtifactsBinCoreFx21 { get; private set; } + public DirectoryPath ArtifactsBinCoreFx30 { get; private set; } + public DirectoryPath ArtifactsBinFullFx472 { get; private set; } public ICollection ToClean { get; private set; } public BuildDirectories( DirectoryPath artifactsDir, + DirectoryPath nativeDir, DirectoryPath buildArtifactDir, DirectoryPath testResultsOutputDir, DirectoryPath nugetRootDir, DirectoryPath artifactsBinDir, - DirectoryPath artifactsBinFullFxDir, - DirectoryPath artifactsBinFullFxPortableDir, - DirectoryPath artifactsBinFullFxCmdlineDir, - DirectoryPath artifactsBinFullFxILMergeDir, - DirectoryPath artifactsBinCoreFx21Dir + DirectoryPath artifactsBinPortableDir, + DirectoryPath artifactsBinCmdlineDir, + DirectoryPath artifactsBinCoreFx21Dir, + DirectoryPath artifactsBinCoreFx30Dir, + DirectoryPath artifactsBinFullFx472Dir ) { Artifacts = artifactsDir; + Native = nativeDir; BuildArtifact = buildArtifactDir; TestResultsOutput = testResultsOutputDir; NugetRoot = nugetRootDir; ArtifactsBin = artifactsBinDir; - ArtifactsBinFullFx = artifactsBinFullFxDir; - ArtifactsBinFullFxPortable = artifactsBinFullFxPortableDir; - ArtifactsBinFullFxCmdline = artifactsBinFullFxCmdlineDir; - ArtifactsBinFullFxILMerge = artifactsBinFullFxILMergeDir; + ArtifactsBinPortable = artifactsBinPortableDir; + ArtifactsBinCmdline = artifactsBinCmdlineDir; ArtifactsBinCoreFx21 = artifactsBinCoreFx21Dir; + ArtifactsBinCoreFx30 = artifactsBinCoreFx30Dir; + ArtifactsBinFullFx472 = artifactsBinFullFx472Dir; ToClean = new[] { Artifacts, + Native, BuildArtifact, TestResultsOutput, NugetRoot, ArtifactsBin, - ArtifactsBinFullFx, - ArtifactsBinFullFxPortable, - ArtifactsBinFullFxCmdline, - ArtifactsBinFullFxILMerge, - ArtifactsBinCoreFx21 + ArtifactsBinPortable, + ArtifactsBinCmdline, + ArtifactsBinCoreFx21, + ArtifactsBinCoreFx30, + ArtifactsBinFullFx472 }; } } diff --git a/build/utils/utils.cake b/build/utils/utils.cake index 9628d6bac1..29b89498e0 100644 --- a/build/utils/utils.cake +++ b/build/utils/utils.cake @@ -86,67 +86,6 @@ void Build(BuildParameters parameters) }); } -void ILRepackGitVersionExe(bool includeLibGit2Sharp, DirectoryPath target, DirectoryPath ilMerge, string configuration, string dotnetVersion) -{ - var exeName = "GitVersion.exe"; - var keyFilePath = "./src/key.snk"; - - var targetDir = target + "/"; - var ilMergeDir = ilMerge + "/"; - var targetPath = targetDir + exeName; - string outFilePath = ilMergeDir + exeName; - - CleanDirectory(ilMergeDir); - CreateDirectory(ilMergeDir); - - var sourcePattern = targetDir + "*.dll"; - var sourceFiles = GetFiles(sourcePattern); - - if (!includeLibGit2Sharp) - { - var excludePattern = "**/LibGit2Sharp.dll"; - sourceFiles = sourceFiles - GetFiles(excludePattern); - } - var settings = new ILRepackSettings { AllowDup = "", Keyfile = keyFilePath, Internalize = true, NDebug = true, TargetKind = TargetKind.Exe, TargetPlatform = TargetPlatformVersion.v4, XmlDocs = false }; - - if (IsRunningOnUnix()) - { - var libFolder = GetDirectories($"**/GitVersionExe/bin/{configuration}/{dotnetVersion}").FirstOrDefault(); - settings.Libs = new List { libFolder }; - } - - ILRepack(outFilePath, targetPath, sourceFiles, settings); - - CopyFileToDirectory("./LICENSE", ilMergeDir); - CopyFileToDirectory(targetDir + "GitVersion.pdb", ilMergeDir); - - Information("Copying libgit2sharp files.."); - - if (!includeLibGit2Sharp) { - CopyFileToDirectory(targetDir + "LibGit2Sharp.dll", ilMergeDir); - } - CopyFileToDirectory(targetDir + "LibGit2Sharp.dll.config", ilMergeDir); - CopyDirectory(targetDir + "/lib/", ilMergeDir + "/lib/"); -} - -void PublishILRepackedGitVersionExe(bool includeLibGit2Sharp, DirectoryPath ilMergDir, DirectoryPath outputDir, BuildParameters parameters) -{ - var targetDir = parameters.Paths.Directories.ArtifactsBinFullFx; - var configuration = parameters.Configuration; - var dotnetVersion = parameters.FullFxVersion; - - ILRepackGitVersionExe(includeLibGit2Sharp, targetDir, ilMergDir, configuration, dotnetVersion); - CopyDirectory(ilMergDir, outputDir); - - if (includeLibGit2Sharp) { - CopyFiles("./src/GitVersionExe/NugetAssets/*.ps1", outputDir); - } - - // Copy license & Copy GitVersion.XML (since publish does not do this anymore) - CopyFileToDirectory("./LICENSE", outputDir); - CopyFileToDirectory("./src/GitVersionExe/bin/" + configuration + "/" + dotnetVersion + "/GitVersion.xml", outputDir); -} - void UpdateTaskVersion(FilePath taskJsonPath, string taskId, GitVersion gitVersion) { var taskJson = ParseJsonFromFile(taskJsonPath);