Search code examples
visual-studiomsbuildreleaserelease-management

Visual Studio - How to remove a reference in Release mode


I'm developing a library for use in other apps and this library has lots of debugging and logging statements thanks to NLog.

Is it possible to exclude the reference to NLog.dll when I switch to release mode?

Cheers,


Solution

  • You can manually edit the csproj file, and do something like this:

    <Reference Include="NLog" Condition="'$(Configuration)' == 'Debug'" />
    

    This only makes it reference that assembly in Debug. I wouldn't recommend doing this often though, because this behavior isn't reflected in the references list in Visual Studio when you change the configuration. It does work when compiling though