aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.Native/WixNativeExe.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core.Native/WixNativeExe.cs')
-rw-r--r--src/WixToolset.Core.Native/WixNativeExe.cs28
1 files changed, 4 insertions, 24 deletions
diff --git a/src/WixToolset.Core.Native/WixNativeExe.cs b/src/WixToolset.Core.Native/WixNativeExe.cs
index 9ae758ca..fb41b2f2 100644
--- a/src/WixToolset.Core.Native/WixNativeExe.cs
+++ b/src/WixToolset.Core.Native/WixNativeExe.cs
@@ -7,7 +7,6 @@ namespace WixToolset.Core.Native
7 using System.ComponentModel; 7 using System.ComponentModel;
8 using System.Diagnostics; 8 using System.Diagnostics;
9 using System.IO; 9 using System.IO;
10 using System.Reflection;
11 10
12 internal class WixNativeExe 11 internal class WixNativeExe
13 { 12 {
@@ -81,35 +80,16 @@ namespace WixToolset.Core.Native
81 { 80 {
82 if (String.IsNullOrEmpty(PathToWixNativeExe)) 81 if (String.IsNullOrEmpty(PathToWixNativeExe))
83 { 82 {
84 var path = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), WixNativeExeFileName); 83 var result = typeof(WixNativeExe).Assembly.FindFileRelativeToAssembly(WixNativeExeFileName, searchNativeDllDirectories: true);
85 var possiblePaths = path;
86 84
87 var found = File.Exists(path); 85 if (!result.Found)
88 if (!found && AppContext.GetData("NATIVE_DLL_SEARCH_DIRECTORIES") is string searchDirectoriesString)
89 {
90 possiblePaths = searchDirectoriesString;
91 var separatorChar = Path.PathSeparator;
92 var searchDirectories = searchDirectoriesString?.Split(separatorChar);
93 foreach (var directoryPath in searchDirectories)
94 {
95 var possiblePath = Path.Combine(directoryPath, WixNativeExeFileName);
96 if (File.Exists(possiblePath))
97 {
98 path = possiblePath;
99 found = true;
100 break;
101 }
102 }
103 }
104
105 if (!found)
106 { 86 {
107 throw new PlatformNotSupportedException( 87 throw new PlatformNotSupportedException(
108 $"Could not find platform specific '{WixNativeExeFileName}'", 88 $"Could not find platform specific '{WixNativeExeFileName}'",
109 new FileNotFoundException($"Could not find internal piece of WiX Toolset from: {possiblePaths}", WixNativeExeFileName)); 89 new FileNotFoundException($"Could not find internal piece of WiX Toolset from: {result.PossiblePaths}", WixNativeExeFileName));
110 } 90 }
111 91
112 PathToWixNativeExe = path; 92 PathToWixNativeExe = result.Path;
113 } 93 }
114 } 94 }
115 95