Skip to content

Commit

Permalink
Fix GitVersion on non-Windows platforms
Browse files Browse the repository at this point in the history
Use `GitVersion.Tool` instead of `GitVersion.CommandLine` so it works on Linux and macOS.
  • Loading branch information
martincostello committed Jan 6, 2023
1 parent 727b044 commit 18528b8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
"commands": [
"dotnet-cake"
]
},
"GitVersion.Tool": {
"version": "5.11.1",
"commands": [
"dotnet-gitversion"
]
}
}
}
6 changes: 3 additions & 3 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var configuration = Argument<string>("configuration", "Release");
// EXTERNAL NUGET TOOLS
//////////////////////////////////////////////////////////////////////

#Tool "GitVersion.CommandLine&version=5.11.1"
#Tool "xunit.runner.console&version=2.4.2"

//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -113,12 +112,13 @@ Task("__UpdateAssemblyVersionInformation")
.Does(() =>
{
var gitVersionSettings = new ProcessSettings()
.SetRedirectStandardOutput(true);
.SetRedirectStandardOutput(true)
.WithArguments(args => args.Append("gitversion"));

try
{
IEnumerable<string> outputLines;
StartProcess(gitVersionPath, gitVersionSettings, out outputLines);
StartProcess("dotnet", gitVersionSettings, out outputLines);

var output = string.Join("\n", outputLines);
gitVersionOutput = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(output);
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if (-Not $SkipToolPackageRestore.IsPresent)

Write-Verbose -Message "Restoring tools from NuGet..."

$NuGetOutput = Invoke-Expression "& dotnet tool install Cake.Tool --version 3.0.0"
$NuGetOutput = Invoke-Expression "& dotnet tool restore"
Write-Verbose ($NuGetOutput | Out-String)

Pop-Location
Expand Down

0 comments on commit 18528b8

Please sign in to comment.