Wednesday, August 5, 2009

Visual Studio reference based on output type

We use CSLA in our application. We keep the source code in a vendor branch in our SVN repository. We then keep a debug as well as a release build of CSLA. We have a reference to the debug build in our project because we want to be able to step into the CSLA source code from time to time to see what is happening.

Here is the problem I encountered: I wanted to be able to have the reference to the CSLA library change based upon the output type. I didn't find anything that directly addressed my particular scenario. I was able to piece together a solution that addressed my needs.

This is what I had originally.


<Reference Include="Csla, Version=3.6.2.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\CSLA.NET\Csla.dll</HintPath>
</Reference>

And this is what solved my problem.


<Reference Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
Include="Csla, Version=3.6.2.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\CSLA.NET\Debug\Csla.dll</HintPath>
</Reference>
<Reference Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "
Include="Csla, Version=3.6.2.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\CSLA.NET\Release\Csla.dll</HintPath>
</Reference>

No comments: