Search code examples
c#visual-studio-2008project

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


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?


Solution

  • 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.