From 22672837ce4248778cbe3ad0b0056c3998a33a84 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 24 Dec 2018 07:32:57 -0800 Subject: Move wixnative.*.exe in Core.Native.nupkg into arch folder Moving the native executable to a subdirectory in the Core.Native to avoid NuGet warning about non-managed code files in "lib" folder. Also, better support NCrunch by ignoring wixnative.exe --- src/WixToolset.Core.Native/WixNativeExe.cs | 36 +++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src/WixToolset.Core.Native/WixNativeExe.cs') 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 internal class WixNativeExe { private const int FiveMinutesInMilliseconds = 300000; - private static readonly string PathToWixNativeExe; + private static readonly object PathToWixNativeExeLock = new object(); + private static string PathToWixNativeExe; private readonly string commandLine; private readonly List stdinLines = new List(); - static WixNativeExe() - { - PathToWixNativeExe = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), "wixnative.x86.exe"); - } - public WixNativeExe(params object[] args) { this.commandLine = String.Join(" ", QuoteArgumentsAsNecesary(args)); @@ -39,10 +35,7 @@ namespace WixToolset.Core.Native public IEnumerable Run() { - if (!File.Exists(PathToWixNativeExe)) - { - throw new FileNotFoundException($"Could not find internal piece of WiX Toolset at: {PathToWixNativeExe}", PathToWixNativeExe); - } + EnsurePathToWixNativeExeSet(); var wixNativeInfo = new ProcessStartInfo(PathToWixNativeExe, this.commandLine) { @@ -88,6 +81,29 @@ namespace WixToolset.Core.Native return stdoutLines; } + private static void EnsurePathToWixNativeExeSet() + { + lock (PathToWixNativeExeLock) + { + if (String.IsNullOrEmpty(PathToWixNativeExe)) + { + var path = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), @"x86\wixnative.x86.exe"); + + if (!File.Exists(path)) + { + path = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), "wixnative.x86.exe"); + + if (!File.Exists(path)) + { + throw new FileNotFoundException($"Could not find internal piece of WiX Toolset at: {path}", path); + } + } + + PathToWixNativeExe = path; + } + } + } + private static IEnumerable QuoteArgumentsAsNecesary(object[] args) { foreach (var arg in args) -- cgit v1.2.3-55-g6feb