Reputation: 19087
I do still have an outstanding question that I am not sure of the answer.
When I followed the tutorials to create a C++/CLI wrapper for my DLL I had to add a reference to the DLL to the project:
No problem with that, as such. But here is the thing, the reference path is:
D:\My Programs\2017\MSAToolsLibrary\MSAToolsLibrary\bin\x86\Release\MSAToolsLibrary.dll
I actually have two DLL files. One for x86 and one for x64. Can I set up the wrapper project files in such a way that it references the x64 file and x86 file respectively based on the build configuration?
This is my VCXPROJ file:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
[snip]
<ItemGroup>
<Reference Include="MSAToolsLibrary">
<HintPath>..\..\MSAToolsLibrary\MSAToolsLibrary\bin\x86\Release\MSAToolsLibrary.dll</HintPath>
</Reference>
[snip]
</Project>
I can see a reference to the DLL but I can't see a specific reference for x64 and x86 respectively.
OK, I added the wrapper project into I real solution. x64 is building OK:
But when I set the configuration to x86 I have some problems. There is a small triangle on the references and the errors in the properties:
As you will see from my comment on the existing answer, I am using $(PlatformTarget)
in the hint. But it seems there is somewhere else we need to adjust references that I can't work out.
OK, If I open the project on it's own in Visual Studio then I can toggle the platforms fine. But when the project is part of my larger project, it does not like it. That is when it fails.
Interestingly, if I am in my master project, and set to the x86 platform, and then in this added project I remove the reference to the DLL and go to add it again (the x86 flavour):
I do not have this problem in the local solution. It seems like I have to do my development in the local solution and compile there, outside of my master project solution. :(
Upvotes: 3
Views: 725
Reputation: 10875
Edit the <HintPath>
to be
<HintPath>..\..\MSAToolsLibrary\MSAToolsLibrary\bin\$(Platform)\$(Configuration)\MSAToolsLibrary.dll</HintPath>
Upvotes: 2