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

peterchen picture peterchen · Mar 29, 2009 · Viewed 8.5k times · Source

When adding a user control or a project reference to a VS 2008 C# project, I can add only one configuration of the assembly. Is it possible to add separate configurations, depending on the configuration of the container project.

E.g. I am developing a user control, and I am working on a sample application. I want to add the user control so that a debug build of the sample will use the debug build of the user control, and the release build of the sample the release build of the user control.

Any suggestions?

Answer

Salvatore Previti picture Salvatore Previti · Feb 15, 2011
<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.