tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
DotnetHelper.cs
Go to the documentation of this file.
1#if NET6_0_OR_GREATER
2using System;
3using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6#endif
7
9{
10#if NET6_0_OR_GREATER
14 public static class DotnetHelper
15 {
21 public static IEnumerable<string> GetPotentialDotnetPaths(bool isWindows)
22 {
23 var enviromentPath = Environment.GetEnvironmentVariable("PATH");
24 if (enviromentPath == null)
25 return Enumerable.Empty<string>();
26
27 var paths = enviromentPath.Split(';');
28
29 var exeName = "dotnet";
30 IEnumerable<string> enumerator;
31 if (isWindows)
32 {
33 exeName += ".exe";
34 enumerator = new List<string>(paths)
35 {
36 "C:/Program Files/dotnet",
37 "C:/Program Files (x86)/dotnet",
38 };
39 }
40 else
41 enumerator = paths
42 .Select(x => x.Split(':'))
43 .SelectMany(x => x)
44 .Concat(new List<string>(2)
45 {
46 "/usr/bin",
47 "/usr/share/bin",
48 "/usr/local/share/dotnet",
49 });
50
51 enumerator = enumerator.Select(x => Path.Combine(x, exeName));
52
53 return enumerator;
54 }
55 }
56#endif
57}