title: Any CPU dependent on C++/CLI dependent on native C dll (any cpu for c++/cli)
body: <p>Here's my problem.
  I am wrapping a C dll in C#. To do this, I am first writing a C++/CLI wrapper. The native C library is linked to the C++/CLI wrapper. (Linker properties in C++/cli project).</p>
  
  <p>Here's how it is all organised now:
  - The native C .lib: both x86 and 64bit.</p>
  
  <ul>
  <li>1 solution containing 2 projects:
  
  <ul>
  <li>C++/CLI wrapper project to which is linked native C .lib</li>
  <li>C# project referencing C++/CLI project</li>
  </ul></li>
  </ul>
  
  <p>My problem comes from the fact that I need C# to target "Any CPU". But this option is not available in C++/CLI since it compiles directly to native code.</p>
  
  <p>My idea to solve this is:
  - Compile C++/CLI wrapper in x86 and then change the config and compile to 64 bit. When it compiles, I would like to tell it which dll to take based on the platform. ie: if compiling in 64bit, link 64 bit native C dll, else if x86, link x86 native C.
  - With this done, I should then be able to have Any CPU target in my C# platform. Here again, instead of referencing my C++/CLI wrapper project, I would reference the required dll based on the target platform.</p>
  
  <p>My questions are:</p>
  
  <ul>
  <li>How to I tell the C++/CLI project which .lib to link to based on the target platform?</li>
  <li>How to I tell the C# project which C++/CLI dll to reference based on the target platform?</li>
  </ul>
  
  <p>Let me add that the <strong>C# project a CLASS LIBRARY</strong> to be used by an x86 or x64 client. </p>
  
  <p>I hope my question is clear enough. Any helps would be appreciated !</p>
  
  <p><strong>UPDATE</strong> based on:<a href="https://stackoverflow.com/questions/2583732/conditional-references-in-net-project-possible-to-get-rid-of-warning">Conditional references in .NET project, possible to get rid of warning?</a>...</p>
  
  <p>So now I've edited my .csproj file using a condition to reference the dll as follows:</p>
  
  <pre><code>&lt;ItemGroup&gt;
      &lt;Reference Include="AlibCppWrapper, Version=1.0.4303.21410, Culture=neutral, PublicKeyToken=c0c17a53adc44091, processorArchitecture=AMD64"
                 Condition="$(Platform) == 'x64'"&gt;
        &lt;SpecificVersion&gt;False&lt;/SpecificVersion&gt;
        &lt;HintPath&gt;..\x64\Debug\AlibCppWrapper.dll&lt;/HintPath&gt;
      &lt;/Reference&gt;
      &lt;Reference Include="AlibCppWrapper, Version=1.0.4303.21410, Culture=neutral, PublicKeyToken=c0c17a53adc44091, processorArchitecture=x86"
                 Condition="$(Platform) == 'x86'"&gt;
        &lt;SpecificVersion&gt;False&lt;/SpecificVersion&gt;
        &lt;HintPath&gt;..\Debug\AlibCppWrapper.dll&lt;/HintPath&gt;
      &lt;/Reference&gt;
    &lt;/ItemGroup&gt;
  </code></pre>
  
  <p>Unfortunately this doesn't work as the $(Platform) is set to AnyCPU...</p>