Microsoft.Owin.Host.HttpListener isn't being copied to a referencing projects' build output

657 Views Asked by At

I am referencing a one project in Visual Studio solution from another project in the same solution. The project being referenced (Project B) has Microsoft.Owin.Host.HttpListener nuget package and so the .dll referenced in it. The project that is referencing project B (Project A) is being built. The output folder gets all those dlls referenced in Project B, except Microsoft.Owin.Host.HttpListener.dll even though it is marked as Copy Local - true.

The Microsoft.Owin.Host.HttpListener.dll is the only one that I've faced so far that refuses to be copied to the Project A's build output as a part of MSBuild's _CopyFilesMarkedCopyLocal step regardless of the settings.

I've tried to add it to a entries in app.config, it didn't help.

I've arranged the sample project showcasing the referencing problem and uploaded it to GitHub here.

You are free to play with the settings.

I've check out the related questions in Stackoverflow before asking this and they are not answered or unrelated.

Please give me a hint how to get the .HttpListener.dll to be copied along with other .dlls to a referencing projects output as expected.

2

There are 2 best solutions below

1
On BEST ANSWER

With the help of my team members I was able to get to the root of the problem. Compiler was omitting HttpListener dll as it wasn't being used anywhere in code of Project A or B explicitly. Thus I've added the following line to Project B's code:

//Dummy line to bypass the optimization.
Trace.TraceInformation(typeof(Microsoft.Owin.Host.HttpListener.OwinHttpListener).FullName);

This created an actual dependency on HttpListener.dll and it started to be included in Project A's output.

0
On

Yes this stupid referencing optimization is completely stupid and totally immature regarding reflection.

In my case I have same issue as you and opted for:

using Microsoft.Owin.Host.HttpListener;
...
    _log.Debug("Loading type: "+ typeof(OwinHttpListener) + "..."); // Hack to force copy of Microsoft.Owin.Host.HttpListener.dll on target referencing project