From c7a1b6b6ea12b3f231d3d8f83590bda74b9284e5 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 10 May 2020 12:51:16 +1000 Subject: The directory separator on non-Windows platforms is ':' --- src/WixToolset.Core.Native/WixNativeExe.cs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Core.Native/WixNativeExe.cs b/src/WixToolset.Core.Native/WixNativeExe.cs index 063485d3..2ea5146e 100644 --- a/src/WixToolset.Core.Native/WixNativeExe.cs +++ b/src/WixToolset.Core.Native/WixNativeExe.cs @@ -8,6 +8,7 @@ namespace WixToolset.Core.Native using System.Diagnostics; using System.IO; using System.Reflection; + using System.Runtime.InteropServices; internal class WixNativeExe { @@ -82,28 +83,29 @@ namespace WixToolset.Core.Native if (String.IsNullOrEmpty(PathToWixNativeExe)) { var path = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), WixNativeExeFileName); + var possiblePaths = path; - if (!File.Exists(path)) + var found = File.Exists(path); + if (!found && AppContext.GetData("NATIVE_DLL_SEARCH_DIRECTORIES") is string searchDirectoriesString) { - var searchDirectoriesString = AppContext.GetData("NATIVE_DLL_SEARCH_DIRECTORIES") as string; - var searchDirectories = searchDirectoriesString?.Split(';'); - if (searchDirectories != null) + possiblePaths = searchDirectoriesString; + var separatorChar = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ';' : ':'; + var searchDirectories = searchDirectoriesString?.Split(separatorChar); + foreach (var directoryPath in searchDirectories) { - foreach (string directoryPath in searchDirectories) + var possiblePath = Path.Combine(directoryPath, WixNativeExeFileName); + if (File.Exists(possiblePath)) { - var possiblePath = Path.Combine(directoryPath, WixNativeExeFileName); - if (File.Exists(possiblePath)) - { - path = possiblePath; - break; - } + path = possiblePath; + found = true; + break; } } } - if (!File.Exists(path)) + if (!found) { - throw new FileNotFoundException($"Could not find internal piece of WiX Toolset at: {path}", path); + throw new FileNotFoundException($"Could not find internal piece of WiX Toolset at: {possiblePaths}", WixNativeExeFileName); } PathToWixNativeExe = path; -- cgit v1.2.3-55-g6feb