move dotnet-format global tool out of Lifetime (#2109)

This commit is contained in:
Brendan Forster
2020-02-24 20:04:35 -04:00
committed by GitHub
parent eee57895ed
commit 3932e939eb
4 changed files with 17 additions and 5 deletions

View File

@@ -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()

View File

@@ -51,7 +51,6 @@ public class Lifetime : FrostingLifetime<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.

View File

@@ -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}'");
}
}