2

I have a Visual Studio (2017) C# solution which is structured like this:

  • Solution
    • ExeProject
    • DLLProject
      • NuGet-Dependency to Stateless package ("Stateless" is the name of the package)

The DLLProject hides the dependency within its interfaces, i.e. the usage of the Stateless library is supposed to be an implementation detail of DLLProject.

The ExeProject accesses only the public interfaces and factories of DLLProject.

Due to reasons which go beyond the scope of this question, ExeProject targets .Net Framework 4.6.1, while DLLProject targets .Net Standard 2.0.

This compiles fine, but when debugging, the Stateless.dll is not found by the executable.

Is it possible to automatically deploy that DLL when linking against DLLProject without adding a Stateless NuGet dependency to the ExeProject?

Tim Meyer
  • 10,998
  • 7
  • 48
  • 84
  • Why do you want to avoid adding a nuget dependency? This is exactly what they are designed for. – Bradley Uffner Apr 18 '19 at 11:55
  • @BradleyUffner Maintainability, Compatibility, Testability, Interface Segregation etc. I want to be able to alter/switch out/remove the library in question without having to modify the `ExeProject`. It's not that important in the minimal example I provided, but the real task at hand has multiple of these issues. – Tim Meyer Apr 18 '19 at 17:50
  • Can you make DLLProject .Net Framework 4.6.1? Should "just work" if its all in the same solution. – mxmissile Apr 18 '19 at 18:04
  • @mxmissile `DLLProject` is additionally used in environments where .Net Framework is not available, so unfortunately, no. – Tim Meyer Apr 18 '19 at 18:21

1 Answers1

1

In .NET Core this transitive NuGet dependencies work automatically.

On .NET Framework, there is a "Copy Local" option for referenced libraries. Make sure that it is set to True for the problematic one.

Update

For your case, .NET Framework App and .NET Standard lib, the setup requires manual modification of the .NET Framework app's .csproj file. Please follow: Copy all dependencies from .Net Standard libraries to .Net Framework Console application

Lesiak
  • 12,048
  • 2
  • 17
  • 41
  • My Exe project targets.NET Framework (it targets Desktops specifically) while the DLL targets .Net Standard. I updated the question to include that detail. Any chance to get it to work automatically in that case? – Tim Meyer Apr 18 '19 at 18:00
  • Updated the answer. – Lesiak Apr 18 '19 at 20:04