@joebigelow / wix / commits / 67007599

Use NATIVE_DLL_SEARCH_DIRECTORIES to support cross-platform wixnative.exe

Sean Hall committed May 9, 2020 at 21:08 UTC 670075995cf1b78d0a66e1a7678fd2facc8958ff
4 files changed +26 -14
src/WixToolset.Core.Native/WixNativeExe.cs
+20 -1
@@ -11,6 +11,7 @@ namespace WixToolset.Core.Native
11
12 internal class WixNativeExe
13 {
14 + private const string WixNativeExeFileName = "wixnative.exe";
15 private static string PathToWixNativeExe;
16
17 private readonly string commandLine;
@@ -80,7 +81,25 @@ namespace WixToolset.Core.Native
81 {
82 if (String.IsNullOrEmpty(PathToWixNativeExe))
83 {
83 - var path = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), "wixnative.x86.exe");
84 + var path = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), WixNativeExeFileName);
85 +
86 + if (!File.Exists(path))
87 + {
88 + var searchDirectoriesString = AppContext.GetData("NATIVE_DLL_SEARCH_DIRECTORIES") as string;
89 + var searchDirectories = searchDirectoriesString?.Split(';');
90 + if (searchDirectories != null)
91 + {
92 + foreach (string directoryPath in searchDirectories)
93 + {
94 + var possiblePath = Path.Combine(directoryPath, WixNativeExeFileName);
95 + if (File.Exists(possiblePath))
96 + {
97 + path = possiblePath;
98 + break;
99 + }
100 + }
101 + }
102 + }
103
104 if (!File.Exists(path))
105 {
src/WixToolset.Core.Native/WixToolset.Core.Native.nuspec
+1 -3
@@ -25,12 +25,10 @@
25 <file src="$id$.dll" target="lib\netstandard2.0" />
26
27 <!--
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 - -->
28 <file src="..\Win32\wixnative.x86.exe" target="lib\netstandard2.0" />
29 <file src="..\Win32\wixnative.x86.pdb" target="lib\netstandard2.0" />
30 <file src="..\x64\wixnative.amd64.exe" target="lib\netstandard2.0" />
31 <file src="..\x64\wixnative.amd64.pdb" target="lib\netstandard2.0" />
32 + -->
33 </files>
34 </package>
src/wixnative/runtime.win.WixToolset.Core.Native.nuspec
+4 -4
@@ -14,9 +14,9 @@
14 </metadata>
15
16 <files>
17 - <file src="Win32\wixnative.x86.exe" target="runtimes\win-x86\native" />
18 - <file src="Win32\wixnative.x86.pdb" target="runtimes\win-x86\native" />
19 - <file src="x64\wixnative.amd64.exe" target="runtimes\win-x64\native" />
20 - <file src="x64\wixnative.amd64.pdb" target="runtimes\win-x64\native" />
17 + <file src="Win32\wixnative.exe" target="runtimes\win-x86\native" />
18 + <file src="Win32\wixnative.pdb" target="runtimes\win-x86\native" />
19 + <file src="x64\wixnative.exe" target="runtimes\win-x64\native" />
20 + <file src="x64\wixnative.pdb" target="runtimes\win-x64\native" />
21 </files>
22 </package>
src/wixnative/wixnative.vcxproj
+1 -6
@@ -23,16 +23,11 @@
23 </ProjectConfiguration>
24 </ItemGroup>
25
26 - <PropertyGroup>
27 - <NameSuffix Condition=" '$(Platform)'=='Win32' ">x86</NameSuffix>
28 - <NameSuffix Condition=" '$(Platform)'=='x64' ">amd64</NameSuffix>
29 - </PropertyGroup>
30 -
26 <PropertyGroup Label="Globals">
27 <ProjectGuid>{8497EC72-B8D0-4272-A9D0-7E9D871CEFBF}</ProjectGuid>
28 <ConfigurationType>Application</ConfigurationType>
29 <ProjectSubSystem>Console</ProjectSubSystem>
35 - <TargetName>wixnative.$(NameSuffix)</TargetName>
30 + <TargetName>wixnative</TargetName>
31 <PlatformToolset>v141</PlatformToolset>
32 <CharacterSet>Unicode</CharacterSet>
33 <Description>Native component of WixToolset.Core</Description>