|
1 | 1 | using System; |
| 2 | +using System.Collections.Generic; |
2 | 3 | using System.Diagnostics; |
3 | 4 | using System.IO; |
4 | 5 | using System.Reflection; |
@@ -40,12 +41,18 @@ internal static string Rid |
40 | 41 | internal static readonly Lazy<string> _DotExePath = new Lazy<string>(() => |
41 | 42 | { |
42 | 43 | // Depending on the method of deployment, there are several possible directories to look for dot |
43 | | - string[] possibleLocations = [ |
44 | | - Path.Combine(AppContext.BaseDirectory, "runtimes", Rid, "native"), |
45 | | - Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), |
46 | | - Path.GetDirectoryName(AppContext.BaseDirectory), |
47 | | - "" |
48 | | - ]; |
| 44 | + // The DOT_BINARY_PATH environment variable can be set to point to a specific location, which will be checked first. |
| 45 | + var dotBinaryPath = Environment.GetEnvironmentVariable("DOT_BINARY_PATH"); |
| 46 | + var possibleLocations = new List<string>(); |
| 47 | + if (!string.IsNullOrEmpty(dotBinaryPath)) |
| 48 | + { |
| 49 | + possibleLocations.Add(dotBinaryPath); |
| 50 | + } |
| 51 | + possibleLocations.Add(Path.Combine(AppContext.BaseDirectory, "runtimes", Rid, "native")); |
| 52 | + possibleLocations.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); |
| 53 | + possibleLocations.Add(Path.GetDirectoryName(AppContext.BaseDirectory)); |
| 54 | + possibleLocations.Add(""); |
| 55 | + |
49 | 56 | return possibleLocations.Where(d => d != null).Select(dir => Path.Combine(dir, "dot")).FirstOrDefault(File.Exists) |
50 | 57 | ?? possibleLocations.Where(d => d != null).Select(dir => Path.Combine(dir, "dot.exe")).FirstOrDefault(File.Exists) |
51 | 58 | ?? throw new InvalidOperationException("Could not find path to dot binary in any of: " + string.Join(", ", possibleLocations)); |
|
0 commit comments