This repository was archived by the owner on Jul 18, 2024. It is now read-only.
forked from JetBrains/teamcity-csharp-interactive
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDotNetBuildServerShutdown.cs
53 lines (48 loc) · 1.99 KB
/
DotNetBuildServerShutdown.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// ReSharper disable UnusedMember.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedType.Global
// ReSharper disable StringLiteralTypo
namespace HostApi;
using Internal.DotNet;
/// <summary>
/// The dotnet build server command is used to shut down build servers that are started from dotnet.
/// </summary>
[Target]
public partial record DotNetBuildServerShutdown(
// Specifies the set of command line arguments to use when starting the tool.
IEnumerable<string> Args,
// Specifies the set of environment variables that apply to this process and its child processes.
IEnumerable<(string name, string value)> Vars,
// Build servers to shut down. By default, all servers are shut down.
IEnumerable<DotNetBuildServer> Servers,
// Overrides the tool executable path.
string ExecutablePath = "",
// Specifies the working directory for the tool to be started.
string WorkingDirectory = "",
// Specifies a short name for this operation.
string ShortName = "")
{
public DotNetBuildServerShutdown(params string[] args)
: this(args, [], [])
{ }
public IStartInfo GetStartInfo(IHost host)
{
if (host == null) throw new ArgumentNullException(nameof(host));
return host.CreateCommandLine(ExecutablePath)
.WithShortName(ToString())
.WithWorkingDirectory(WorkingDirectory)
.WithVars(Vars.ToArray())
.WithArgs("build-server", "shutdown")
.AddArgs(GetServerArg().ToArray())
.AddArgs(Args.ToArray());
}
public override string ToString() => "dotnet build-server shutdown".GetShortName(ShortName);
private IEnumerable<string> GetServerArg() =>
Servers.Select(server => server switch
{
DotNetBuildServer.MSBuild => "--msbuild",
DotNetBuildServer.VbCsCompiler => "--vbcscompiler",
DotNetBuildServer.Razor => "--razor",
_ => throw new ArgumentOutOfRangeException()
});
}