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
Rob Mensching committed
Dec 24, 2018 at 07:32 UTC
22672837ce4248778cbe3ad0b0056c3998a33a84
3 files changed
+35
-14
src/WixToolset.Core.Native/WixNativeExe.cs
+26
-10
@@ -12,16 +12,12 @@ namespace WixToolset.Core.Native
12
internal class WixNativeExe
13
{
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;
17
18
private readonly string commandLine;
19
private readonly List<string> stdinLines = new List<string>();
20
20
- static WixNativeExe()
21
- {
22
- PathToWixNativeExe = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), "wixnative.x86.exe");
23
- }
24
-
21
public WixNativeExe(params object[] args)
22
{
23
this.commandLine = String.Join(" ", QuoteArgumentsAsNecesary(args));
@@ -39,10 +35,7 @@ namespace WixToolset.Core.Native
35
36
public IEnumerable<string> Run()
37
{
42
- if (!File.Exists(PathToWixNativeExe))
43
- {
44
- throw new FileNotFoundException($"Could not find internal piece of WiX Toolset at: {PathToWixNativeExe}", PathToWixNativeExe);
45
- }
38
+ EnsurePathToWixNativeExeSet();
39
40
var wixNativeInfo = new ProcessStartInfo(PathToWixNativeExe, this.commandLine)
41
{
@@ -88,6 +81,29 @@ namespace WixToolset.Core.Native
81
return stdoutLines;
82
}
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
+
107
private static IEnumerable<string> QuoteArgumentsAsNecesary(object[] args)
108
{
109
foreach (var arg in args)
src/WixToolset.Core.Native/WixToolset.Core.Native.nuspec
+4
-4
@@ -28,9 +28,9 @@
28
These native executables are included in this .nupkg to place the .exe correctly for tests to work.
29
That are ignored when published. The dependency above is used when publishing the tools.
30
-->
31
- <file src="..\Win32\wixnative.x86.exe" target="lib\netstandard2.0" />
32
- <file src="..\Win32\wixnative.x86.pdb" target="lib\netstandard2.0" />
33
- <file src="..\x64\wixnative.amd64.exe" target="lib\netstandard2.0" />
34
- <file src="..\x64\wixnative.amd64.pdb" target="lib\netstandard2.0" />
31
+ <file src="..\Win32\wixnative.x86.exe" target="lib\netstandard2.0\x86" />
32
+ <file src="..\Win32\wixnative.x86.pdb" target="lib\netstandard2.0\x86" />
33
+ <file src="..\x64\wixnative.amd64.exe" target="lib\netstandard2.0\amd64" />
34
+ <file src="..\x64\wixnative.amd64.pdb" target="lib\netstandard2.0\amd64" />
35
</files>
36
</package>
src/wixnative/wixnative.v3.ncrunchproject
new
+5
@@ -0,0 +1,5 @@
1
+<ProjectConfiguration>
2
+ <Settings>
3
+ <IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
4
+ </Settings>
5
+</ProjectConfiguration>
\ No newline at end of file