为最新的 .NET 核心获取 .NET Web Api 的正确依赖项 [英] Getting the correct dependencies for .NET Web Api for the latest .NET core

查看:24
本文介绍了为最新的 .NET 核心获取 .NET Web Api 的正确依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在尝试以一种也适用于 Linux 的方式(使用 .NET Core)创建一个 ASP.NET Web Api 项目.当我在 Visual Studio 中创建一个新的 Web Api 项目时,它看起来像是在 ASP.NET 5 处于 beta5 时使用依赖项和代码脚手架,到目前为止我已经让它工作了,如果我在 DNX 中使用 beta5 版本使用dnx web"运行它.

问题是我正在尝试使用最新的 rc1 版本或至少是 beta8,我可以使用dnvm"获取这些版本的 ASP.NET,但 Visual Studio 仍然使用旧的依赖项和脚手架创建项目.

我什至不知道应该将它们更新到哪个版本,因为不断有高于 beta8 的新预发布版本,如果我只是将所有内容都更新到最新版本,那么什么都不起作用 - 我无法使用 'dnx web' 因为我遇到了某种奇怪的异常.

那么有没有办法告诉我应该将哪些版本的依赖项与哪些版本的 ASP.NET 5 一起使用?代码也是如此,因为由于缺少某些方法,显然默认的脚手架代码甚至不适用于最新版本.

现在甚至可以在 .NET Core 上创建一个有效的 Web 应用程序吗?因为 ASP.NET 5 即将发布,所以我认为它现在可以正常工作了.

解决方案

这就是 ASP.NET and Web Tools 2015 (Beta7) 为我所做的.我想 beta8 (

忘了提到这对我来说适用于 dnx beta7(带有 beta7 VS 工具的 dnx beta8 不适用)

So I'm trying to create a ASP.NET Web Api project in a way that it works on Linux as well (using .NET Core). When I create a new Web Api project in Visual Studio, it looks like it uses dependencies and code scaffolding from back when ASP.NET 5 was in beta5 and so far I've gotten it to work, if I use the beta5 version in DNX to run it with 'dnx web'.

The problem is that I'm trying to use the latest rc1 version or at least beta8 and I can get those versions of ASP.NET with 'dnvm', but Visual Studio still creates projects using the older dependencies and scaffolding.

I can't even tell what version should I update them to because there are constantly new pre-release versions higher than beta8 and if I just update everything to the latest version then nothing works - I can't run it with 'dnx web' because I get some sort of weird exception.

So is there a way to tell - what versions of dependencies should I use with what versions of ASP.NET 5? And same goes for code, because apparently the default scaffolded code doesn't even work with the latest versions due to some methods being missing.

Is it even possible to create a working Web Application on the .NET Core right now? Because ASP.NET 5 is about to be released, so I would think that it would work alright by this point.

解决方案

This is what ASP.NET and Web Tools 2015 (Beta7) does for me. I suppose beta8 (http://www.microsoft.com/en-us/download/details.aspx?id=49442) will scaffold beta8 packages.

"dependencies": {
 "EntityFramework.Commands": "7.0.0-beta7",
 "EntityFramework.SqlServer": "7.0.0-beta7",
 "Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta7",
 "Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta7",
 "Microsoft.AspNet.Authentication.Google": "1.0.0-beta7",
 "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta7",
 "Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta7",
 "Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
 "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta7",
 "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta7",
 "Microsoft.AspNet.Mvc": "6.0.0-beta7",
 "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta7",
 "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
 "Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
 "Microsoft.AspNet.StaticFiles": "1.0.0-beta7",
 "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta7",
 "Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta7",
 "Microsoft.Framework.Configuration.Json": "1.0.0-beta7",
 "Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta7",
 "Microsoft.Framework.Logging": "1.0.0-beta7",
 "Microsoft.Framework.Logging.Console": "1.0.0-beta7",
 "Microsoft.Framework.Logging.Debug" : "1.0.0-beta7",
 "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta7"
},

EDIT: For WebAPI this is:

"dependencies": {
  "Microsoft.AspNet.Mvc": "6.0.0-beta7",
  "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
  "Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
  "Microsoft.AspNet.StaticFiles": "1.0.0-beta7"
},

Most probably you have old version of VS tooling. You may check your version of ASP.NET and Web Tools under About Visual Studio in Help menu. Reinstall or post exact message you get from build system or from runtime (including IIS).

EDIT: forgot to mention that is works for me for dnx beta7 (dnx beta8 with beta7 VS tooling does not)

这篇关于为最新的 .NET 核心获取 .NET Web Api 的正确依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆