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
The only way I know is to take the reference out completely and call the assembly via reflection. Then, you should only log if the assembly loads.
I can't think of a good way to do this. Unless maybe you wrote a stub reference for NLog.dll. Since you are using the reference in your code I don't see how you could just remove it in your release.
Probably too late now but in the future you could write a class to wrap NLog.dll and then just change it in one place so it wouldn't actually log in the release version. Or have some sort of flag.
There is no reason for removing a reference in case you are sure that no code will be in use from that DLL. In that case you can simply remove DLL.
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
Why would you want to do that?
If you want to stop logging, you can programatically turn off the logging. The performance hit will be minimal. (I have had great success with NLog even when logging cross process.)
Otherwise, you need to wrap it as described above.
-Scott