diff options
Diffstat (limited to 'src/WixToolset.Core.Native/WixNativeExe.cs')
-rw-r--r-- | src/WixToolset.Core.Native/WixNativeExe.cs | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/WixToolset.Core.Native/WixNativeExe.cs b/src/WixToolset.Core.Native/WixNativeExe.cs index 90ab0042..3bd340bc 100644 --- a/src/WixToolset.Core.Native/WixNativeExe.cs +++ b/src/WixToolset.Core.Native/WixNativeExe.cs | |||
@@ -12,16 +12,12 @@ namespace WixToolset.Core.Native | |||
12 | internal class WixNativeExe | 12 | internal class WixNativeExe |
13 | { | 13 | { |
14 | private const int FiveMinutesInMilliseconds = 300000; | 14 | private const int FiveMinutesInMilliseconds = 300000; |
15 | private static readonly string PathToWixNativeExe; | 15 | private static readonly object PathToWixNativeExeLock = new object(); |
16 | private static string PathToWixNativeExe; | ||
16 | 17 | ||
17 | private readonly string commandLine; | 18 | private readonly string commandLine; |
18 | private readonly List<string> stdinLines = new List<string>(); | 19 | private readonly List<string> stdinLines = new List<string>(); |
19 | 20 | ||
20 | static WixNativeExe() | ||
21 | { | ||
22 | PathToWixNativeExe = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), "wixnative.x86.exe"); | ||
23 | } | ||
24 | |||
25 | public WixNativeExe(params object[] args) | 21 | public WixNativeExe(params object[] args) |
26 | { | 22 | { |
27 | this.commandLine = String.Join(" ", QuoteArgumentsAsNecesary(args)); | 23 | this.commandLine = String.Join(" ", QuoteArgumentsAsNecesary(args)); |
@@ -39,10 +35,7 @@ namespace WixToolset.Core.Native | |||
39 | 35 | ||
40 | public IEnumerable<string> Run() | 36 | public IEnumerable<string> Run() |
41 | { | 37 | { |
42 | if (!File.Exists(PathToWixNativeExe)) | 38 | EnsurePathToWixNativeExeSet(); |
43 | { | ||
44 | throw new FileNotFoundException($"Could not find internal piece of WiX Toolset at: {PathToWixNativeExe}", PathToWixNativeExe); | ||
45 | } | ||
46 | 39 | ||
47 | var wixNativeInfo = new ProcessStartInfo(PathToWixNativeExe, this.commandLine) | 40 | var wixNativeInfo = new ProcessStartInfo(PathToWixNativeExe, this.commandLine) |
48 | { | 41 | { |
@@ -88,6 +81,29 @@ namespace WixToolset.Core.Native | |||
88 | return stdoutLines; | 81 | return stdoutLines; |
89 | } | 82 | } |
90 | 83 | ||
84 | private static void EnsurePathToWixNativeExeSet() | ||
85 | { | ||
86 | lock (PathToWixNativeExeLock) | ||
87 | { | ||
88 | if (String.IsNullOrEmpty(PathToWixNativeExe)) | ||
89 | { | ||
90 | var path = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), @"x86\wixnative.x86.exe"); | ||
91 | |||
92 | if (!File.Exists(path)) | ||
93 | { | ||
94 | path = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), "wixnative.x86.exe"); | ||
95 | |||
96 | if (!File.Exists(path)) | ||
97 | { | ||
98 | throw new FileNotFoundException($"Could not find internal piece of WiX Toolset at: {path}", path); | ||
99 | } | ||
100 | } | ||
101 | |||
102 | PathToWixNativeExe = path; | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | |||
91 | private static IEnumerable<string> QuoteArgumentsAsNecesary(object[] args) | 107 | private static IEnumerable<string> QuoteArgumentsAsNecesary(object[] args) |
92 | { | 108 | { |
93 | foreach (var arg in args) | 109 | foreach (var arg in args) |