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.
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:
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": {}
}
},
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.
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.
What can I do about it?
EDIT
I also created a normal Class Library, installed the dependencies above with and gave it a try. Normal Class Library project built fine.
Update: This can now be fixed by upgrading to AutoFixture.AutoMoq 3.41.0 or later.
Original Answer:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With