在 ASP.NET 核心应用程序 (RC2) 中使用 net451 库
Using net451 libraries in an ASP.NET Core application (RC2)
我正在尝试将我的 ASP.NET 5 个 RC1 项目升级到 ASP.NET 核心 RC2 项目。我遇到了一些问题,因为我使用的库尚不支持 .NET Core,所以我必须 运行 完整框架。这在 RC1 中运行良好,但我无法找出在 RC2 中实现此目标的正确方法。
我有一个 class 库可以恢复包并正确构建。我有一个引用 class 库的测试项目。当我尝试构建测试项目时,出现以下错误:
> dotnet build
Project TenantService (.NETFramework,Version=v4.5.1) was previously compiled. Skipping compilation.
Project TenantServiceTests (.NETCoreApp,Version=v1.0) will be compiled because expected outputs are missing
Compiling TenantServiceTests for .NETCoreApp,Version=v1.0
C:\projects\TenantService\test\TenantServiceTests\project.json(25,23): error NU1001: The dependency mscorlib could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency mscorlib could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(25,23): error NU1001: The dependency mscorlib could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency mscorlib could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(26,21): error NU1001: The dependency System could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(26,21): error NU1001: The dependency System could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(27,26): error NU1001: The dependency System.Core could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System.Core could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(27,26): error NU1001: The dependency System.Core could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System.Core could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency Microsoft.CSharp could not be resolved.
这两个项目的 project.json 文件如下所示:
src\TenantService\project.json
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24027",
"Microsoft.Extensions.Options": "1.0.0-rc2-final",
"Newtonsoft.Json": "8.0.4-beta1",
"MongoDB.Driver": "2.2.4",
"StackExchange.Redis": "1.1.603"
},
"frameworks": {
"net451": {}
}
}
test\TenantServiceTests\project.json
{
"version": "1.0.0-*",
"testrunner": "xunit",
"description": "TenantServiceTests Class Library",
"authors": [ "Henning" ],
"dependencies": {
"xunit": "2.1.0",
"TenantService": "1.0.0-*",
"dotnet-test-xunit": "1.0.0-rc2-build10015"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-rc2-3002702"
}
},
"imports": [
"net451"
]
}
}
}
我应该如何正确设置它才能在我的应用程序中使用 net451 库?
The dependency mscorlib could not be resolved
我 运行 昨天遇到了同样的问题。问题是测试项目的 project.json
是针对 netcoreapp1.0
。相反,您可以将 net451
框架作为您正在测试的服务的目标,并且应该 "just work".
{
"version": "1.0.0-*",
"testrunner": "xunit",
"description": "TenantServiceTests Class Library",
"authors": [ "Henning" ],
"dependencies": {
"xunit": "2.1.0",
"TenantService": "1.0.0-*",
"dotnet-test-xunit": "1.0.0-rc2-build10015"
},
"frameworks": {
"net451": { }
}
}
有关此检查的更多详细信息,请查看详细说明 .NET Platform Standard.
的 Migrating from ASP.NET 5 RC1 to ASP.NET Core. Another great resource is the markdown file out on the corefx repo
我正在尝试将我的 ASP.NET 5 个 RC1 项目升级到 ASP.NET 核心 RC2 项目。我遇到了一些问题,因为我使用的库尚不支持 .NET Core,所以我必须 运行 完整框架。这在 RC1 中运行良好,但我无法找出在 RC2 中实现此目标的正确方法。
我有一个 class 库可以恢复包并正确构建。我有一个引用 class 库的测试项目。当我尝试构建测试项目时,出现以下错误:
> dotnet build
Project TenantService (.NETFramework,Version=v4.5.1) was previously compiled. Skipping compilation.
Project TenantServiceTests (.NETCoreApp,Version=v1.0) will be compiled because expected outputs are missing
Compiling TenantServiceTests for .NETCoreApp,Version=v1.0
C:\projects\TenantService\test\TenantServiceTests\project.json(25,23): error NU1001: The dependency mscorlib could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency mscorlib could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(25,23): error NU1001: The dependency mscorlib could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency mscorlib could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(26,21): error NU1001: The dependency System could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(26,21): error NU1001: The dependency System could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(27,26): error NU1001: The dependency System.Core could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System.Core could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(27,26): error NU1001: The dependency System.Core could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System.Core could not be resolved.
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency Microsoft.CSharp could not be resolved.
这两个项目的 project.json 文件如下所示:
src\TenantService\project.json
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24027",
"Microsoft.Extensions.Options": "1.0.0-rc2-final",
"Newtonsoft.Json": "8.0.4-beta1",
"MongoDB.Driver": "2.2.4",
"StackExchange.Redis": "1.1.603"
},
"frameworks": {
"net451": {}
}
}
test\TenantServiceTests\project.json
{
"version": "1.0.0-*",
"testrunner": "xunit",
"description": "TenantServiceTests Class Library",
"authors": [ "Henning" ],
"dependencies": {
"xunit": "2.1.0",
"TenantService": "1.0.0-*",
"dotnet-test-xunit": "1.0.0-rc2-build10015"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-rc2-3002702"
}
},
"imports": [
"net451"
]
}
}
}
我应该如何正确设置它才能在我的应用程序中使用 net451 库?
The dependency mscorlib could not be resolved
我 运行 昨天遇到了同样的问题。问题是测试项目的 project.json
是针对 netcoreapp1.0
。相反,您可以将 net451
框架作为您正在测试的服务的目标,并且应该 "just work".
{
"version": "1.0.0-*",
"testrunner": "xunit",
"description": "TenantServiceTests Class Library",
"authors": [ "Henning" ],
"dependencies": {
"xunit": "2.1.0",
"TenantService": "1.0.0-*",
"dotnet-test-xunit": "1.0.0-rc2-build10015"
},
"frameworks": {
"net451": { }
}
}
有关此检查的更多详细信息,请查看详细说明 .NET Platform Standard.
的 Migrating from ASP.NET 5 RC1 to ASP.NET Core. Another great resource is the markdown file out on the corefx repo