Getting the correct dependencies for .NET Web Api for the latest .NET core

夙愿已清 提交于 2019-12-24 05:26:31

问题


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.


回答1:


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)



来源:https://stackoverflow.com/questions/33156090/getting-the-correct-dependencies-for-net-web-api-for-the-latest-net-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!