Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
move dotnet-format global tool out of Lifetime
  • Loading branch information
shiftkey committed Feb 24, 2020
commit bdb3b717c6d2ef581774463c4389623ff4c04ea5
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": [
"sourcelink"
]
},
"dotnet-format": {
"version": "3.3.111304",
"commands": [
"dotnet-format"
]
}
}
}
1 change: 0 additions & 1 deletion build/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class Context : FrostingContext

public Project[] Projects { get; set; }

public FilePath DotNetFormatToolPath { get; set; }
public FilePath GitVersionToolPath { get; set; }

public DotNetCoreTestSettings GetTestSettings()
Expand Down
1 change: 0 additions & 1 deletion build/Lifetime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public override void Setup(Context context)
new Project { Name = "Octokit.Tests.Integration", Path = "./Octokit.Tests.Integration/Octokit.Tests.Integration.csproj", IntegrationTests = true }
};

context.DotNetFormatToolPath = ToolInstaller.DotNetCoreToolInstall(context, "dotnet-format", "3.1.37601", "dotnet-format");
context.GitVersionToolPath = ToolInstaller.DotNetCoreToolInstall(context, "GitVersion.Tool", "5.1.3", "dotnet-gitversion");

// Calculate semantic version.
Expand Down
14 changes: 11 additions & 3 deletions build/Tasks/FormatCode.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
using System;
using Cake.Common;
using Cake.Common.Diagnostics;
using Cake.Common.IO;
using Cake.Core;
using Cake.Core.IO;
using Cake.Frosting;

public sealed class FormatCode : FrostingTask<Context>
{
public override void Run(Context context)
{
int result = context.StartProcess(context.DotNetFormatToolPath);
if (result != 0)
var exitCode = context.StartProcess("dotnet", new ProcessSettings
{
throw new Exception($"Failed to execute {context.DotNetFormatToolPath} ({result})");
Arguments = $"format"
});

if (exitCode != 0)
{
throw new Exception($"Failed to format code - got exit code '{exitCode}'");
}
}

Expand Down