3

I have a solution with 2 projects:

Project 1: Wrapper.Dll which contains a NLog wrapper. NLog and NLog.Extended have been installed with Nuget.

Project 2: is an ASP.Net MVC project which contains a reference to project 1.

When I try to run the web project, it throws an exception because NLog tries to load a target renderer from NLog.Extended.Dll.

If I check the bin directory of Wrapper.dll, I have NLog.Dll and NLog.Extended.Dll.

If I check the bin directory of the Web project, I only have NLog.dll.

How can I tell Visual Studio to copy the NLog.Extended.Dll from project 1 to project 2?

EDIT: Adding some dead code that use something from NLog.Extended.Dll makes the file copied. Is there any cleaner solution?

Thanks

JuChom
  • 5,717
  • 5
  • 45
  • 78
  • 1
    The solution to the more general problem can be found at: http://stackoverflow.com/a/7856474/149399 – PenFold Feb 06 '14 at 14:00
  • I know this is an old question but if you can remember, can you explain how you resolved it by adding some dead code? I can't work out what is in NLog.Extended that can be referenced, and I'm not sure where to reference it from. Thanks! – Kate Nov 03 '15 at 18:00
  • 1
    I'm not using NLog anymore, but looking at the source code on github you can create an instance of it in a dummy class https://github.com/NLog/NLog/blob/master/src/NLog.Extended/Targets/MessageQueueTarget.cs – JuChom Nov 03 '15 at 19:36
  • Thanks so much for following up and so quickly - this did the job! – Kate Nov 04 '15 at 10:22

2 Answers2

1

Unfortunately no, there is no cleaner solution. If no objects from the NLog.Extended assembly are referenced (directly or indirectly) from your code, it will not copy it. This is of course a problem since the layouts are just strings and not a direct reference. You could use a post-build event, but that's an uglier solution in my opinion.

Jay
  • 381
  • 1
  • 10
0

You could add a reference to NLog.Extended.dll in the web project if it depends on it.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • 1
    I don't want to add the reference directly to my web project. I will investigate and post the solution here if I find a pretty one – JuChom Apr 23 '12 at 16:54