@joebigelow / wix-1 / commits / c7a1b6b6

The directory separator on non-Windows platforms is ':'

Sean Hall committed May 10, 2020 at 12:51 UTC c7a1b6b6ea12b3f231d3d8f83590bda74b9284e5
1 file changed +15 -13
src/WixToolset.Core.Native/WixNativeExe.cs
+15 -13
@@ -8,6 +8,7 @@ namespace WixToolset.Core.Native
8 using System.Diagnostics;
9 using System.IO;
10 using System.Reflection;
11 + using System.Runtime.InteropServices;
12
13 internal class WixNativeExe
14 {
@@ -82,28 +83,29 @@ namespace WixToolset.Core.Native
83 if (String.IsNullOrEmpty(PathToWixNativeExe))
84 {
85 var path = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), WixNativeExeFileName);
86 + var possiblePaths = path;
87
86 - if (!File.Exists(path))
88 + var found = File.Exists(path);
89 + if (!found && AppContext.GetData("NATIVE_DLL_SEARCH_DIRECTORIES") is string searchDirectoriesString)
90 {
88 - var searchDirectoriesString = AppContext.GetData("NATIVE_DLL_SEARCH_DIRECTORIES") as string;
89 - var searchDirectories = searchDirectoriesString?.Split(';');
90 - if (searchDirectories != null)
91 + possiblePaths = searchDirectoriesString;
92 + var separatorChar = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ';' : ':';
93 + var searchDirectories = searchDirectoriesString?.Split(separatorChar);
94 + foreach (var directoryPath in searchDirectories)
95 {
92 - foreach (string directoryPath in searchDirectories)
96 + var possiblePath = Path.Combine(directoryPath, WixNativeExeFileName);
97 + if (File.Exists(possiblePath))
98 {
94 - var possiblePath = Path.Combine(directoryPath, WixNativeExeFileName);
95 - if (File.Exists(possiblePath))
96 - {
97 - path = possiblePath;
98 - break;
99 - }
99 + path = possiblePath;
100 + found = true;
101 + break;
102 }
103 }
104 }
105
104 - if (!File.Exists(path))
106 + if (!found)
107 {
106 - throw new FileNotFoundException($"Could not find internal piece of WiX Toolset at: {path}", path);
108 + throw new FileNotFoundException($"Could not find internal piece of WiX Toolset at: {possiblePaths}", WixNativeExeFileName);
109 }
110
111 PathToWixNativeExe = path;