Skip to content

Commit c612c99

Browse files
committed
(build) use cake DotNetLocalToolsModule
1 parent a49d80a commit c612c99

File tree

17 files changed

+67
-151
lines changed

17 files changed

+67
-151
lines changed

build/Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<PackageReference Include="Cake.Compression" Version="0.2.6" />
55
<PackageReference Include="Cake.Frosting" Version="2.2.0" />
66
<PackageReference Include="Cake.Incubator" Version="7.0.0" />
7+
<PackageReference Include="Cake.DotNetLocalTools.Module" Version="1.0.2" />
78

89
<PackageReference Include="Cake.Docker" Version="1.1.2" />
910

build/artifacts/Program.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
using Artifacts;
2+
using Common.Lifetime;
3+
using Common.Utilities;
24

35
return new CakeHost()
46
.UseContext<BuildContext>()
5-
.UseStartup<Startup>()
7+
.UseLifetime<BuildLifetime>()
8+
.UseTaskLifetime<BuildTaskLifetime>()
9+
.UseRootDirectory()
10+
.InstallToolsFromRootManifest()
611
.Run(args);

build/artifacts/Startup.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

build/build/Program.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
using Build;
2+
using Common.Lifetime;
3+
using Common.Utilities;
24

35
return new CakeHost()
46
.UseContext<BuildContext>()
5-
.UseStartup<Startup>()
7+
.UseLifetime<BuildLifetime>()
8+
.UseTaskLifetime<BuildTaskLifetime>()
9+
.UseRootDirectory()
10+
.InstallToolsFromRootManifest()
11+
.InstallNugetTool(Tools.NugetCmd, Tools.Versions[Tools.NugetCmd])
612
.Run(args);

build/build/Startup.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Cake.DotNetLocalTools.Module;
2+
3+
namespace Common.Utilities;
4+
5+
public static class ServicesExtensions
6+
{
7+
public static CakeHost UseRootDirectory(this CakeHost host)
8+
{
9+
host = host.ConfigureServices(services => services.UseWorkingDirectory(Extensions.GetRootDirectory()));
10+
return host;
11+
}
12+
13+
public static CakeHost InstallToolsFromRootManifest(this CakeHost host)
14+
{
15+
host = host.UseModule<LocalToolsModule>().InstallToolsFromManifest(Extensions.GetRootDirectory().CombineWithFilePath("dotnet-tools.json").FullPath);
16+
return host;
17+
}
18+
19+
public static CakeHost InstallNugetTool(this CakeHost host, string toolName, string toolVersion)
20+
{
21+
var toolUrl = new Uri($"nuget:?package={toolName}&version={toolVersion}");
22+
return host.ConfigureServices(services => services.UseTool(toolUrl));
23+
}
24+
}

build/common/Utilities/ServicesExtensions.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

build/common/Utilities/Tools.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,8 @@ public class Tools
44
{
55
public const string NugetCmd = "NuGet.CommandLine";
66

7-
public const string GitVersion = "GitVersion.Tool";
8-
public const string GitReleaseManager = "GitReleaseManager.Tool";
9-
public const string Codecov = "Codecov.Tool";
10-
public const string Wyam2 = "Wyam2.Tool";
11-
127
public static readonly Dictionary<string, string> Versions = new()
138
{
14-
{ NugetCmd, "6.0.0" },
15-
16-
{ GitVersion, "5.8.3" },
17-
{ GitReleaseManager, "0.13.0" },
18-
{ Codecov, "1.13.0" },
19-
{ Wyam2, "3.0.0-rc3&prerelease" },
9+
{ NugetCmd, "6.1.0" },
2010
};
2111
}

build/docker/Program.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
using Common.Lifetime;
2+
using Common.Utilities;
13
using Docker;
24

35
return new CakeHost()
46
.UseContext<BuildContext>()
5-
.UseStartup<Startup>()
7+
.UseLifetime<BuildLifetime>()
8+
.UseTaskLifetime<BuildTaskLifetime>()
9+
.UseRootDirectory()
10+
.InstallToolsFromRootManifest()
611
.Run(args);

build/docker/Startup.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)