0

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

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.

enter image description here

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!

Leanne
  • 77
  • 9

1 Answers1

0

For anyone else having a similar issue, well turns out it was pulling in the correct reference, it just did not show the correct path in the properties. However when I searched through the output after the build, it was indeed grabbing the reference file from the allocated location.

The .manifest file did nothing, so I deleted that, all that is needed for this to work is the <ItemGroup> conditions in the .csproj file and it should use the reference file you want even if it does not update the location in properties.

Leanne
  • 77
  • 9