【问题标题】:Getting FileNotFound Exception when adding project dependency to a project which uses another Nuget Package将项目依赖项添加到使用另一个 Nuget 包的项目时出现 FileNotFound 异常
【发布时间】:2017-12-18 22:42:57
【问题描述】:

我有一个项目 A 的设置,它是 NetStandard 库项目。另一个项目 A.Frame 是带有通用类文件 Class1.cs 的 Net Framework Library 项目(Class1.cs 是两个项目中的链接文件)。 Class1.cs 有一个函数 FooA(),如果项目类型是 Netstandard,则返回“Netstandard”,如果项目类型是 NetFramework,则返回“NetFramework”。同一解决方案项目 B 中的另一个项目有一个函数 FooB(),它调用函数 FooA() 并返回结果。 我已经将整个设置打包在一个 Nuget 包中,这样 Bait 和 Switch 将允许 Netstandard 和 NetFramework 使用它们各自的 dll。 现在我在不同解决方案的不同项目中使用 Nuget 包,例如解决方案 B 的项目 C。项目 C 是一个 NetStandard 库项目,其函数 Bar() 从项目 B 调用函数 FooB()。当我尝试测试时这在使用项目 C 的项目依赖项的单元测试项目上我得到System.IO.FileNotFoundException: 'Could not load file or assembly 'ProjectB, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

当我在 NetFramework 库上使用 Nuget 包时,我得到了所需的输出。 有什么我遗漏的或者我需要对我的 Nuget 包设置做些什么。

【问题讨论】:

    标签: c# .net


    【解决方案1】:

    您的项目是使用 packages.config 还是新的 PackageReference 格式? PackageReference 的依赖关系解析使用transitive restore 进程。使用 .NET Standard,packages.config isn't fully supported

    【讨论】:

      猜你喜欢
      • 2021-04-02
      • 2017-06-27
      • 2019-03-19
      • 2018-05-29
      • 2013-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多