Skip to content

Commit 357516d

Browse files
committed
Make the olewoo DLLs dependencies conditional based on MSBuild's bitness because it's built with unamanged C++ and thus cannot be compatible with "Any CPU" so we have to load the right DLLs at the build time for the build task to work correctly. We use an inline build task to get the bitness of the MSBuild process and then set the reference using the output.
1 parent 1c8e621 commit 357516d

File tree

7 files changed

+54
-2
lines changed

7 files changed

+54
-2
lines changed
49.5 KB
Binary file not shown.

Rubberduck.Deployment.Build/OleWoo/olewoo.dll.config renamed to Rubberduck.Deployment.Build/OleWoo/x32/olewoo.dll.config

File renamed without changes.
467 KB
Binary file not shown.
File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/></startup></configuration>

Rubberduck.Deployment.Build/OleWoo/olewoo_interop.dll renamed to Rubberduck.Deployment.Build/OleWoo/x64/olewoo_interop.dll

File renamed without changes.

Rubberduck.Deployment.Build/Rubberduck.Deployment.Build.csproj

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,44 @@
88
<AssemblyName>Rubberduck.Deployment.Build</AssemblyName>
99
</PropertyGroup>
1010
<Import Project="..\RubberduckBaseMetaProject.csproj" />
11+
<!--
12+
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"
13+
14+
<![CDATA[
15+
System.IntPtr ptr = System.IntPtr.Zero;
16+
17+
if(System.Runtime.InteropServices.Marshal.SizeOf(ptr) == 8)
18+
Bitness = "x64";
19+
else if(System.Runtime.InteropServices.Marshal.SizeOf(ptr) == 4)
20+
Bitness = "x32";
21+
else
22+
Bitness = "Unknown";
23+
]]>
24+
-->
25+
<UsingTask
26+
TaskName="GetMSBuildBitness"
27+
TaskFactory="CodeTaskFactory"
28+
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
29+
<ParameterGroup>
30+
<Bitness ParameterType="System.String" Output="true" />
31+
</ParameterGroup>
32+
<Task>
33+
<Using Namespace="System" />
34+
<Using Namespace="System.Runtime.InteropServices" />
35+
<Code Type="Fragment" Language="cs">
36+
<![CDATA[
37+
IntPtr ptr = IntPtr.Zero;
38+
39+
if(Marshal.SizeOf(ptr) == 8)
40+
Bitness = "x64";
41+
else if(Marshal.SizeOf(ptr) == 4)
42+
Bitness = "x32";
43+
else
44+
Bitness = "Unknown";
45+
]]>
46+
</Code>
47+
</Task>
48+
</UsingTask>
1149
<ItemGroup>
1250
<Reference Include="Microsoft.Build.Framework" />
1351
<Reference Include="Microsoft.Build.Tasks.v4.0" />
@@ -17,11 +55,22 @@
1755
<Reference Include="Microsoft.VisualStudio.Setup.Configuration.Interop">
1856
<HintPath>VisualStudioSetup\Microsoft.VisualStudio.Setup.Configuration.Interop.dll</HintPath>
1957
</Reference>
58+
</ItemGroup>
59+
<Target Name="PreBuildTask" BeforeTargets="PreBuildEvent">
60+
<GetMSBuildBitness>
61+
<Output PropertyName="MSBuildBitness" TaskParameter="Bitness" />
62+
</GetMSBuildBitness>
63+
</Target>
64+
<ItemGroup>
2065
<Reference Include="olewoo">
21-
<HintPath>OleWoo\olewoo.dll</HintPath>
66+
<HintPath>OleWoo\$(MSBuildBitness)\olewoo.dll</HintPath>
2267
</Reference>
2368
<Reference Include="olewoo_interop">
24-
<HintPath>OleWoo\olewoo_interop.dll</HintPath>
69+
<HintPath>OleWoo\$(MSBuildBitness)\olewoo_interop.dll</HintPath>
2570
</Reference>
2671
</ItemGroup>
72+
<ItemGroup>
73+
<Folder Include="OleWoo\x64\" />
74+
<Folder Include="OleWoo\x32\" />
75+
</ItemGroup>
2776
</Project>

0 commit comments

Comments
 (0)