I'm trying to build a project and based on the platform I'm building in, I want a reference file to be added from the allocated location.
When I build in x86, I want the program to use the file located in the \bin
. And the \bin_x64
folder when I build in x64.
Similar to these posts
- Conditionally use 32/64 reference when building in visual studio
- Targeting both 32bit and 64bit with visual studio in the same solution/project
I've added a .manifest file in my project:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity name="DriverLib" processorArchitecture="*" type="win32" version="1.0.0.0"/>
<dependency>
<dependentAssembly>
<assemblyIdentity name="DriverLib" processorArchitecture="x86" type="win32" version="1.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DriverLib" processorArchitecture="amd64" type="win32" version="1.0.0.0"/>
</dependentAssembly>
</dependency>
</assembly>
In file structure below, I have to manually add the DriverLib reference file from the \bin
. Which is not ideal and caused errors when I run using the 64bit platform.
In the project file, I've added the conditions
<ItemGroup Condition="'$(Platform)' == 'x64'">
<WixLibrary Include="DriverLib">
<HintPath>..\..\..\Bin_x64\DriverLib.wixlib</HintPath>
<Name>DriverLib</Name>
</WixLibrary>
</ItemGroup>
<ItemGroup Condition="'$(Platform)' == 'x86'">
<WixLibrary Include="DriverLib">
<HintPath>..\..\..\Bin\DriverLib.wixlib</HintPath>
<Name>DriverLib</Name>
</WixLibrary>
</ItemGroup>
Is there a way to have it were by if I run in platform x86, the correct reference file gets added, and then if I run in x64, the DriverLib.wixlib
for the 32bit is replaced with the 64bit file?
UPDATE
I believe I've narrowed down the problem. The file does add when I run it, but when I run it in 64bit it does not replace the file with the file in the \bin_x64
folder. If I change the directory in the <ItemGroup>
condition for the x86 item to the \bin_x64
, it will then add the file. So somehow it is not using the 64bit <ItemGroup>
. I also tried changing the order of them and placing the condition in the <WixLibrary>
tags, as suggested in the post below.
Something similar to this post:
Any help would be greatly appreciated!