如何在 dotnet Core 中添加最小起订量作为依赖项?
How to add moq as a dependency in dotnet Core?
我的 dotnet 核心应用程序中有以下依赖项:
"dependencies": {
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Moq": "4.0.10827"
},
而且无论我下载的 Moq 是什么版本,它根本不支持,它说:
Package Moq 4.0.10827 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Moq 4.0.10827 supports:
- net35 (.NETFramework,Version=v3.5)
- net40 (.NETFramework,Version=v4.0)
- sl4 (Silverlight,Version=v4.0)
One or more packages are incompatible with .NETCoreApp,Version=v1.0.
但我在这篇博文中读到:Moq on .NET Core that it was possible, i have the nuget plugin in studio code, so it autocompletes packages, i just cannot find any package when i write moq.netcore
Maybe i am asking more of an approach to finding out if such a plugin actually exists, more than an answer, because right now i can't see on nuget if packages are supported in dotnet Core, how do you guys check if it has support? and do you only look for packages on Nuget.org ?
谢谢
编辑:解决方案project.json:
{
"version": "1.0.0-*",
"testRunner": "xunit",
"dependencies": {
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"moq": "4.6.38-alpha"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
}
}
我猜 Nuget 中当前的稳定版本是 4.5.23,在你的代码中你提到它应该是 4.0.10827,这可能是导致问题的原因。
如您的错误所示,Moq 4.0.10827 与 netcoreapp1.0 不兼容,它只支持 4.0,有关 Moq
版本的更多详细信息,请查看 here
我也写过关于.Net core中Moq的博客,就是here。但由于新的变化,我每天都会对此进行更改。
编辑: 根据 DenLilleMand:
4.6.38-alpha works - but e.g. 4.5.3 doesn't work, that complains that Moq 4.5.3 supports net45 and one or more packages are incompatible
with .NETCoreApp V1.0.
我的 dotnet 核心应用程序中有以下依赖项:
"dependencies": {
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Moq": "4.0.10827"
},
而且无论我下载的 Moq 是什么版本,它根本不支持,它说:
Package Moq 4.0.10827 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Moq 4.0.10827 supports:
- net35 (.NETFramework,Version=v3.5)
- net40 (.NETFramework,Version=v4.0)
- sl4 (Silverlight,Version=v4.0)
One or more packages are incompatible with .NETCoreApp,Version=v1.0.
但我在这篇博文中读到:Moq on .NET Core that it was possible, i have the nuget plugin in studio code, so it autocompletes packages, i just cannot find any package when i write moq.netcore
Maybe i am asking more of an approach to finding out if such a plugin actually exists, more than an answer, because right now i can't see on nuget if packages are supported in dotnet Core, how do you guys check if it has support? and do you only look for packages on Nuget.org ?
谢谢
编辑:解决方案project.json:
{
"version": "1.0.0-*",
"testRunner": "xunit",
"dependencies": {
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"moq": "4.6.38-alpha"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
}
}
我猜 Nuget 中当前的稳定版本是 4.5.23,在你的代码中你提到它应该是 4.0.10827,这可能是导致问题的原因。
如您的错误所示,Moq 4.0.10827 与 netcoreapp1.0 不兼容,它只支持 4.0,有关 Moq
版本的更多详细信息,请查看 here我也写过关于.Net core中Moq的博客,就是here。但由于新的变化,我每天都会对此进行更改。
编辑: 根据 DenLilleMand:
4.6.38-alpha works - but e.g. 4.5.3 doesn't work, that complains that Moq 4.5.3 supports net45 and one or more packages are incompatible with .NETCoreApp V1.0.