如何使ASP.NET Core RC2应用程序在具有较旧的第三方依赖性的net46框架上构建 [英] How to make ASP.NET Core RC2 app build on net46 framework with older third party dependencies
问题描述
精细的Asp.Net Core RC1在完整的net45框架上。从Asp.NET Core rc1迁移到rc2我遇到了一个障碍,我不知道如何修复。
应用程序是一个ASP.NET核心应用程序,使用EF6,Autofac,Kendo.MVC,它需要在完整的.Net 4.6框架上运行,因为有使用WCF的参考库。
在从rc1迁移到rc2时,我首先更新NuGet.config文件,指向 https://www.myget.org/F/ aspnetcirelease / api / v3 / index.json
然后我对 project.json进行以下更改
- 从最上面的节点删除version
- 将以下属性添加到complationOptions对象:debugType:portable li>
- 依赖关系:更改
AspNet
至AspNetCore
- 依赖关系:将所有
rc1-final
更改为*
- 检查已经从
6.0重新命名了
MVC
和MVC标签助手
到1.0
- 删除所有依赖关系到
应用程序分析
- 删除
的所有依赖项Microsoft.AspNet.Tooling.Razor
- 将依赖关系添加到
Microsoft.NETCore.App:{type:platform,version:1.0.0- *}
- 广告da新内容对象:
content:[wwwroot,Views,web.config,appsettings.json]
- 更新所有使用语句以引用
AspNetCore。*
而不是AspNet。*
- 更新所有使用语句以引用
然后我用
$ b替换框架对象$ b
框架:{
netcoreapp1.0:{
imported:[
net45
]
}
}
我做一个 dotnet restore
,一切都解决了1包:
错误:Package Kendo.Mvc 2016.1 .412与netcoreapp1.0(.NETCoreApp,Version = v1.0)不兼容。软件包Kendo.Mvc 2016.1.412支持:
错误: - dnx451(DNX,Version = v4.5.1)
错误: - dnxcore50(DNXCore,Version = v5.0)
错误:一或更多的软件包与.NETCoreApp Version = v1.0不兼容。
info:提交还原...
project.json中的错误
软件包Kendo.Mvc 2016.1.412与netcoreapp1.0不兼容(.NETCoreApp,版本= V1.0)。软件包Kendo.Mvc 2016.1.412支持:
- dnx451(DNX,Version = v4.5.1)
- dnxcore50(DNXCore,Version = v5.0)
一个或多个软件包与.NETCoreApp,版本= 1.0。
所以,Kendo.MVC需要参考 net45
或 net451
而不是 dnx451
,但由于这是来自NuGet Feed,我无法更改此。 / p>
你知道是否有一个快速的修复,我可以做,而不是等待下一个版本的Kendo.MVC?
你的做法很近做得好。有一些变化/添加。以下工作与 dotnet restore
然后 dotnet运行
。 完整的代码清单位于GitHub上。
框架
您的框架
失败,因为 .NET Core( netcoreapp
)与.NET Framework不兼容( net
),因此您无法导入 net45
。您的错误表示 Kendo.Mvc
与 dnx451
和 dnxcore50
;导入其中一个。然后为 Kendo.Mvc
依赖的某些软件包添加便携式导入(如果没有,您将看到构建错误,告诉您这样做。)
框架:{
netcoreapp1.0:{
imports:[
dnxcore50,
portable-net45 + win8 + wp8
]
}
}
现在您的应用程序将恢复和构建。但是,它不会运行。
依赖关系
更改您对不具有
type:platform
。否则,您的应用程序将不会自行运行,因为NuGet将会抑制该软件包的资产。
依赖关系:
{
//为清楚起见,其他省略
Microsoft。 NETCore.App:1.0.0- *,
Kendo.Mvc:*
}
运行时
添加 运行时
部分;我们现在在project.json中指定,而不是依赖于 dnvm
。
运行时:{
win8-x64:{}
}
I have a shiny new Asp.Net Core MVC App that references some older net45
libraries.
Works fine with Asp.Net Core RC1 on full net45 framework. Migrating from Asp.NET Core rc1 to rc2 I have hit an obstacle that I don't know how to fix.
The App is a ASP.NET Core App that using EF6, Autofac, Kendo.MVC and it needs to run on the full .Net 4.6 framework as there are references libraries that use WCF.
In migrating from rc1 to rc2 I first update the NuGet.config feed to point to https://www.myget.org/F/aspnetcirelease/api/v3/index.json
then I make the following changes to the project.json
- Remove "version" from the top most node
- Add the following attribute to the complationOptions object: "debugType": "portable"
- dependencies: change
AspNet
toAspNetCore
- dependencies: change all
rc1-final
, to*
- Check that
MVC
andMVC Tag Helpers
have been renamed from6.0
to1.0
- Remove all dependencies to
Application Insights
- Remove all dependencies for
Microsoft.AspNet.Tooling.Razor
- Add a dependency to
"Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0-*" }
- Add a new content object:
"content": [ "wwwroot", "Views", "web.config", "appsettings.json" ]
- Update all using statements to reference
AspNetCore.*
instead ofAspNet.*
- Update all using statements to reference
I then replace the frameworks object with:
"frameworks": {
"netcoreapp1.0": {
"imports": [
"net45"
]
}
}
I do a dotnet restore
and everything resolves exceptfor 1 package:
error: Package Kendo.Mvc 2016.1.412 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Kendo.Mvc 2016.1.412 supports:
error: - dnx451 (DNX,Version=v4.5.1)
error: - dnxcore50 (DNXCore,Version=v5.0)
error: One or more packages are incompatible with .NETCoreApp,Version=v1.0.
info : Committing restore...
Errors in project.json
Package Kendo.Mvc 2016.1.412 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Kendo.Mvc 2016.1.412 supports:
- dnx451 (DNX,Version=v4.5.1)
- dnxcore50 (DNXCore,Version=v5.0)
One or more packages are incompatible with .NETCoreApp,Version=v1.0.
So, Kendo.MVC needs to reference net45
or net451
instead of dnx451
, but since this comes from a NuGet feed, I can't change this.
Do you know if there is a quick fix I can make instead of waiting for the next release of Kendo.MVC?
Your approach is close. Well done. There are a few changes/additions to make. The following works with dotnet restore
then dotnet run
. The full code listing is on GitHub.
frameworks
Your frameworks
fail because .NET Core (netcoreapp
) is not compatible with .NET Framework (net
), so you cannot import net45
. Your errors say that Kendo.Mvc
is compatible with dnx451
and dnxcore50
; import one of those instead. Then add a portable import for some packages on which Kendo.Mvc
depends (if you don't, you will see build errors that tell you to do this.)
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dnxcore50",
"portable-net45+win8+wp8"
]
}
}
Now your app will restore and build. It won't run yet, though.
dependencies
Change your dependency on Microsoft.NETCore.App
to not have the "type" : "platform"
. Otherwise your app will not run on its own, because NuGet will suppress the package's assets.
"dependencies" :
{
// others omitted for clarity
"Microsoft.NETCore.App": "1.0.0-*",
"Kendo.Mvc": "*"
}
runtimes
Add a runtimes
section; we now specify this in project.json instead of relying on dnvm
.
"runtimes": {
"win8-x64": {}
}
这篇关于如何使ASP.NET Core RC2应用程序在具有较旧的第三方依赖性的net46框架上构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!