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 ++++++++++++++++------ .../WixToolset.Core.Native.nuspec | 8 ++--- src/wixnative/wixnative.v3.ncrunchproject | 5 +++ 3 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 src/wixnative/wixnative.v3.ncrunchproject (limited to 'src') 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) diff --git a/src/WixToolset.Core.Native/WixToolset.Core.Native.nuspec b/src/WixToolset.Core.Native/WixToolset.Core.Native.nuspec index 195ea7b6..a99c5ec3 100644 --- a/src/WixToolset.Core.Native/WixToolset.Core.Native.nuspec +++ b/src/WixToolset.Core.Native/WixToolset.Core.Native.nuspec @@ -28,9 +28,9 @@ These native executables are included in this .nupkg to place the .exe correctly for tests to work. That are ignored when published. The dependency above is used when publishing the tools. --> - - - - + + + + diff --git a/src/wixnative/wixnative.v3.ncrunchproject b/src/wixnative/wixnative.v3.ncrunchproject new file mode 100644 index 00000000..319cd523 --- /dev/null +++ b/src/wixnative/wixnative.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file -- cgit v1.2.3-55-g6feb