C# / VS2008: Add separate debug / release references to a project

<Reference Include="MyLibrary">
  <HintPath>..\$(Configuration)\MyLibrary.dll</HintPath>
</Reference>

This add a reference "..\Debug\MyLibrary.dll" if compiled in debug mode or ..\Release\MyLibrary.dll" if compiled in release mode.


You can do this by editing the csproj file; add a "Condition" attribute to the reference.

<Reference Include="Foo" Condition="'$(Configuration)'=='Debug'"/>
<Reference Include="Bar" Condition="'$(Configuration)'=='Release'"/>

However, I would have concerns about what this means for unit testing.


While @Marc Gravell's suggestion will work, is there a reason that you don't want both projects in the same solution? If they are in the same solution, you can add a Project Reference when referencing the User Control project to the sample app's project. When a Project Reference is used, Visual Studio will automatically add the Debug version for a Debug build, and the Release version for the Release build.