Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Different References List for Debug / Release

In my debug build I have a reference to a DLL that is only required in the Debug configuration (the reference is for CodeSite, a logging tool).

Is it possible to exclude this reference in the Release build (my logging class only uses this reference when built in the Debug configuration).

Using VB.NET and VS2008.

like image 393
Simon Temlett Avatar asked Jun 18 '09 14:06

Simon Temlett


2 Answers

Yes this is possible but it will require you to manually edit the .vbproj file. Once you have the file open you'll an XML reference tag for the DLL's you've referenced and it will look like the following

<Reference Include="SomeDllName" />

You need to add a condition property which species it should only be done during debug time

<Reference Include="SomeDllName" Condition="'$(Configuration)'=='Debug'" />
like image 113
JaredPar Avatar answered Nov 16 '22 23:11

JaredPar


It's possible to do this, but you'll need to mess with the project file manually.

We do this in MiscUtil so we can have a .NET 2.0 build and a .NET 3.5 build. For instance:

<ItemGroup Condition=" '$(Configuration)' != 'Release 2.0' ">
  <Reference Include="System.Core">
    <RequiredTargetFramework>3.5</RequiredTargetFramework>
    <Aliases>global</Aliases>
  </Reference>
  <Reference Include="System.Xml.Linq">
    <RequiredTargetFramework>3.5</RequiredTargetFramework>
  </Reference>
</ItemGroup>

That should be enough to get you started :) Basically take the current reference out of where it is in your normal project file, and put it in its own ItemGroup with an appropriate condition.

like image 24
Jon Skeet Avatar answered Nov 16 '22 22:11

Jon Skeet