简体   繁体   English

混合使用.Net Standard 和.Net Framework 时,如何自动部署隐藏的NuGet 依赖项的C# DLL?

[英]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:我有一个 Visual Studio (2017) C# 解决方案,其结构如下:

  • Solution解决方案
    • ExeProject执行项目
    • DLLProject DLL项目
      • NuGet-Dependency to Stateless package ("Stateless" is the name of the package) NuGet-Dependency to Stateless包(“Stateless”是包的名称)

The DLLProject hides the dependency within its interfaces, ie the usage of the Stateless library is supposed to be an implementation detail of DLLProject . DLLProject 在其接口中隐藏了依赖关系,即Stateless库的使用应该是DLLProject的实现细节。

The ExeProject accesses only the public interfaces and factories of DLLProject .ExeProject只能访问公共接口和工厂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 .由于超出此问题范围的原因, ExeProject.Net Framework 4.6.1 DLLProject目标,而DLLProject.Net Standard 2.0目标。

This compiles fine, but when debugging, the Stateless.dll is not found by the executable.这编译得很好,但是在调试时,可执行文件找不到Stateless.dll

Is it possible to automatically deploy that DLL when linking against DLLProject without adding a Stateless NuGet dependency to the ExeProject ?是否可以在链接DLLProject时自动部署该 DLL,而不向DLLProject添加Stateless NuGet 依赖ExeProject

In .NET Core this transitive NuGet dependencies work automatically.在 .NET Core 中,这种可传递的 NuGet 依赖项会自动工作。

On .NET Framework, there is a "Copy Local" option for referenced libraries.在 .NET Framework 上,引用的库有一个“复制本地”选项。 Make sure that it is set to True for the problematic one.确保将有问题的设置为 True。

Update更新

For your case, .NET Framework App and .NET Standard lib, the setup requires manual modification of the .NET Framework app's .csproj file.对于 .NET Framework 应用程序和 .NET Standard 库,安装程序需要手动修改 .NET Framework 应用程序的 .csproj 文件。 Please follow: Copy all dependencies from .Net Standard libraries to .Net Framework Console application请遵循: 将所有依赖项从 .Net Standard 库复制到 .Net Framework Console 应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 根据.NET标准编译.NET Framework项目时,为什么缺少此NuGet依赖项? - Why is this NuGet dependency missing when compiling .NET Framework project depending on .NET Standard? 如何将nuget包.Net Standard嵌入到项目C#中? - How to embed nuget package .Net Standard into a project C#? C#反思:如何判断一个DLL是.NET核心还是.NET框架? - C# reflection: how to tell if a DLL is .NET core or .NET framework? 如何在 c# .net 标准中动态加载本机 dll? - How to dynamically load a native dll in c# .net standard? NuGet 包在 a.Net Standard 2.0 dll 被.Net Framework 和.Net Core 使用 - NuGet packages in a .Net Standard 2.0 dll used by both .Net Framework and .Net Core 本地dll和nuget lib之间的奇怪C#.Net依赖关系 - Strange C#.Net dependency between local dll and nuget lib 如何将 .Net Standard Nuget 包添加到 .Net 4.5 Framework 项目中? - How to add .Net Standard Nuget package into .Net 4.5 Framework Project? C#.Net Dll引用依赖项 - C# .Net Dll References Dependency Visual Studio .NET标准库和.NET Framework项目-NuGet dll清单定义不匹配 - Visual Studio .NET Standard library and .NET Framework project - NuGet dll manifest definition does not match C#:如何将私钥加载到 .net 框架/标准中的 RsaSecurityKey 中? - C#: How to load a private key into RsaSecurityKey in .net Framework/Standard?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM