From 3932e939eb0f91812afc04149d117a49307ff687 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 24 Feb 2020 20:04:35 -0400 Subject: [PATCH] move dotnet-format global tool out of Lifetime (#2109) --- .config/dotnet-tools.json | 6 ++++++ build/Context.cs | 1 - build/Lifetime.cs | 1 - build/Tasks/FormatCode.cs | 14 +++++++++++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 5e9a36e70e..f319224cf0 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -7,6 +7,12 @@ "commands": [ "sourcelink" ] + }, + "dotnet-format": { + "version": "3.3.111304", + "commands": [ + "dotnet-format" + ] } } } \ No newline at end of file diff --git a/build/Context.cs b/build/Context.cs index dc5685f624..b6d538f3ab 100644 --- a/build/Context.cs +++ b/build/Context.cs @@ -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() diff --git a/build/Lifetime.cs b/build/Lifetime.cs index 0075dd74ec..562d3cc35d 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -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. diff --git a/build/Tasks/FormatCode.cs b/build/Tasks/FormatCode.cs index 49353a336e..d8386384cf 100644 --- a/build/Tasks/FormatCode.cs +++ b/build/Tasks/FormatCode.cs @@ -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 { 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}'"); } }