views:

232

answers:

2

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.

+5  A: 

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.

Jon Skeet
+5  A: 

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'" />
JaredPar
Ooh, that's nice - I didn't realise you could add a condition on a single reference.
Jon Skeet
@Jon, I think you can do it on pretty much any entry in a MSBuild file.
JaredPar
Thank you, exactly as required. Thanks also Jon.
Simon Temlett