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

查看:124
本文介绍了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   Path\To\My\Solution\ClassLibrary1\project.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和OS,但都无济于事.

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的targets部分中将"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天全站免登陆