diff --git a/GitVersion.yml b/GitVersion.yml
index b5514654..b67ea5a1 100644
--- a/GitVersion.yml
+++ b/GitVersion.yml
@@ -1,11 +1,13 @@
+mode: ContinuousDeployment
branches:
master:
mode: ContinuousDeployment
increment: Minor
tag: beta
- dotnetcore:
+ develop:
mode: ContinuousDeployment
increment: Minor
tag: alpha
+ source-branches: ['dotnetcore']
ignore:
- sha: []
+ sha: []
\ No newline at end of file
diff --git a/build/Build.csproj b/build/Build.csproj
index db4ad0c4..9583f95e 100644
--- a/build/Build.csproj
+++ b/build/Build.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/build/Context.cs b/build/Context.cs
index 0b224f31..ad77c00b 100644
--- a/build/Context.cs
+++ b/build/Context.cs
@@ -28,6 +28,8 @@ public class Context : FrostingContext
public Project[] Projects { get; set; }
+ public FilePath GitVersionToolPath { get; set; }
+
public DotNetCoreTestSettings GetTestSettings()
{
var settings = new DotNetCoreTestSettings
diff --git a/build/Lifetime.cs b/build/Lifetime.cs
index acf2af1b..fb292c8f 100644
--- a/build/Lifetime.cs
+++ b/build/Lifetime.cs
@@ -63,10 +63,12 @@ public class Lifetime : FrostingLifetime
else
{
context.Information("Installing tools...");
- ToolInstaller.Install(context, "GitVersion.CommandLine", "3.6.2");
ToolInstaller.Install(context, "Octokit.CodeFormatter", "1.0.0-preview");
}
+
+ context.GitVersionToolPath = ToolInstaller.DotNetCoreToolInstall(context, "GitVersion.Tool", "5.0.0", "dotnet-gitversion");
+
// Calculate semantic version.
context.Version = BuildVersion.Calculate(context);
context.Version.Prefix = context.Argument("version", context.Version.Prefix);
diff --git a/build/Utilities/BuildVersion.cs b/build/Utilities/BuildVersion.cs
index 07e9ba94..f1785078 100644
--- a/build/Utilities/BuildVersion.cs
+++ b/build/Utilities/BuildVersion.cs
@@ -30,11 +30,6 @@ public class BuildVersion
public static BuildVersion Calculate(Context context)
{
context.Information("Calculating semantic version...");
- if (context.CoreOnly)
- {
- context.Information("Skipping GitVersion query for local build");
- return new BuildVersion("0.0.0", "dev");
- }
if (!context.IsLocalBuild)
{
diff --git a/build/Utilities/GitVersionRunner.cs b/build/Utilities/GitVersionRunner.cs
index d91de552..17d5e5ca 100644
--- a/build/Utilities/GitVersionRunner.cs
+++ b/build/Utilities/GitVersionRunner.cs
@@ -1,29 +1,13 @@
-using Cake.Common;
-using Cake.Common.Diagnostics;
-using Cake.Common.Tools.GitVersion;
-using Cake.Core;
+using Cake.Common.Tools.GitVersion;
public static class GitVersionRunner
{
- public static GitVersion Run(ICakeContext context, GitVersionOutput outputType)
+ public static GitVersion Run(Context context, GitVersionOutput outputType)
{
- if (context.IsRunningOnWindows())
+ return context.GitVersion(new GitVersionSettings
{
- return context.GitVersion(new GitVersionSettings
- {
- OutputType = outputType
- });
- }
- else
- {
- // On non windows platform, point the GitVersion task at our wrapper script that uses mono to run GitVersion.exe
- context.Information("Overriding GitVersion ToolPath to /bin/sh ./tools/gitversion_wrapper.sh");
- return context.GitVersion(new GitVersionSettings
- {
- OutputType = outputType,
- ToolPath = "/bin/sh",
- ArgumentCustomization = args => args.Prepend("./tools/gitversion_wrapper.sh")
- });
- }
+ OutputType = outputType,
+ ToolPath = context.GitVersionToolPath
+ });
}
}
\ No newline at end of file
diff --git a/build/Utilities/ToolInstaller.cs b/build/Utilities/ToolInstaller.cs
index e61e248b..1a03d215 100644
--- a/build/Utilities/ToolInstaller.cs
+++ b/build/Utilities/ToolInstaller.cs
@@ -1,16 +1,76 @@
-using Cake.Common.Tools.NuGet;
+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
});
}
+
+ 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;
+ }
}
\ No newline at end of file
diff --git a/tools/gitversion_wrapper.sh b/tools/gitversion_wrapper.sh
deleted file mode 100755
index bf0e49d9..00000000
--- a/tools/gitversion_wrapper.sh
+++ /dev/null
@@ -1 +0,0 @@
-mono ./tools/GitVersion.CommandLine/tools/GitVersion.exe "$@"
\ No newline at end of file