Skip to content

Commit

Permalink
move dotnet-format global tool out of Lifetime (#2109)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey authored Feb 25, 2020
1 parent eee5789 commit 3932e93
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 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": [
"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

0 comments on commit 3932e93

Please sign in to comment.