简体   繁体   中英

How to deploy C# DLL of hidden NuGet dependency automatically when mixing .Net Standard and .Net Framework?

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, ie 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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM