tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
DotnetHelper.cs
Go to the documentation of this file.
1using System;
2using System.Linq;
3using System.Threading;
4using System.Threading.Tasks;
5
7
9{
13 static class DotnetHelper
14 {
22 public static async ValueTask<string?> GetDotnetPath(IPlatformIdentifier platformIdentifier, IIOManager ioManager, CancellationToken cancellationToken)
23 {
24 ArgumentNullException.ThrowIfNull(platformIdentifier);
25 ArgumentNullException.ThrowIfNull(ioManager);
26
27 var dotnetPaths = Common.DotnetHelper.GetPotentialDotnetPaths(platformIdentifier.IsWindows)
28 .ToList();
29 var tasks = dotnetPaths
30 .Select(path => ioManager.FileExists(path, cancellationToken))
31 .ToList();
32
33 await Task.WhenAll(tasks);
34
35 var selectedPathIndex = tasks.FindIndex(pathValidTask => pathValidTask.Result);
36
37 if (selectedPathIndex == -1)
38 return null;
39
40 var dotnetPath = dotnetPaths[selectedPathIndex];
41
42 return dotnetPath;
43 }
44 }
45}
Helper methods for working with the dotnet executable.
static async ValueTask< string?> GetDotnetPath(IPlatformIdentifier platformIdentifier, IIOManager ioManager, CancellationToken cancellationToken)
Locate a dotnet executable to use.
Interface for using filesystems.
Definition IIOManager.cs:13
Task< bool > FileExists(string path, CancellationToken cancellationToken)
Check that the file at path exists.
For identifying the current platform.
bool IsWindows
If the current platform is a Windows platform.