Nuget 找不到更新的依赖项 [英] Nuget cannot find newer dependency

查看:29
本文介绍了Nuget 找不到更新的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在 ASP 5 MVC 6 beta8 中创建了一个新项目和一个用于测试的兼容类库.问题出现在我打算用于测试的这个新的Web 类库"项目中.

I've just created a new project in ASP 5 MVC 6 beta8 and a compatible class library for tests. The problem occurs in this new "Web Class Library" project that I intended to use for tests.

这就是我的 project.json 的样子:

This is what my project.json looks like:

{
  "version": "1.0.0-*",
  "description": "ClassLibrary1 Class Library",
  "authors": [ "Me" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",
  "frameworks": {
    "dnx451": { }
  },
  "dependencies": {
    "AutoFixture": "3.36.9",
    "AutoFixture.AutoMoq": "3.36.9",
    "Moq": "4.2.1510.2205"
  }
}

在编译过程中出现以下错误:

During compilation I get the following error:

Severity    Code    Description Project File    Line    Source
Error   NU1001  The dependency moq >= 4.1.1308.2120 could not be resolved.  ClassLibrary1   PathToMySolutionClassLibrary1project.json  1   Build

这就是我的项目引用的样子:

This is what my project's references look like:

我猜问题是 AutoFixture.AutoMoq 需要 "4.1.1308.2120" 版本中的 Moq.查看project.lock.json:

I guess the problem is that AutoFixture.AutoMoq requires Moq in version "4.1.1308.2120". See the project.lock.json:

  "AutoFixture.AutoMoq/3.36.9": {
    "type": "package",
    "dependencies": {
      "autofixture": "3.36.9",
      "moq": "4.1.1308.2120"
    },
    "compile": {
      "lib/net40/Ploeh.AutoFixture.AutoMoq.dll": {}
    },
    "runtime": {
      "lib/net40/Ploeh.AutoFixture.AutoMoq.dll": {}
    }
  },

但是安装的Moq版本比较高"4.2.1510.2205",所以根据报错信息应该可以,其实不然.

However, the installed Moq version is higher "4.2.1510.2205", so according to the error message, it should be fine, but it's not.

如果我将 Moq 降级到所需版本,它可以正常工作,但我宁愿使用最新版本.我已经安装了最新的 nuget 包管理器,重新启动了 VS 和操作系统,但都没有帮助.

It works fine though if I downgrade Moq to the required version, but I'd rather use the latest version. I've installed the latest nuget package manager, restarted VS and OS but neither helped.

我该怎么办?

编辑

我还创建了一个普通的类库,安装了上面的依赖项并试了一下.普通类库项目构建良好.

I also created a normal Class Library, installed the dependencies above with and gave it a try. Normal Class Library project built fine.

推荐答案

更新:现在可以通过升级到 AutoFixture.AutoMoq 3.41.0 或更高版本来解决此问题.

Update: This can now be fixed by upgrading to AutoFixture.AutoMoq 3.41.0 or later.

原答案:

在 project.lock.json 的目标部分中,将moq"大写,以便 AutoMoq 元素如下所示:

In the targets section of project.lock.json capitalize "moq", so that the AutoMoq element looks like this:

"AutoFixture.AutoMoq/3.38.0": {
    "type": "package",
    "dependencies": {
      "autofixture": "3.38.0",
      "Moq": "4.1.1308.2120"
    },

不幸的是,每次重新生成锁定文件时,您都必须再次执行此操作.

Unfortunately, you will have to do this again every time the lock file is regenerated.

这篇关于Nuget 找不到更新的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆