Targeting Runtime for New MVC6 Project in VS 2015

橙三吉。 提交于 2019-12-12 02:24:50

问题


I am using ASP.NET beta 7, VS 2015 on Windows 7.

When I create a new MVC6 project in VS2015 targeting .NET 4.6 framework, my project references look like this:

DNX 4.5.1
DNX Core 5.0

I don't wish to create for cross platform, and would expect my references to look like this (from other tutorials):

ASP.NET 5.0
ASP.NET Core 5.0

From the ASP.NET 5.0 documentation:

What I'm seeing in VS 2015 (no check box option for dnx):

Should I just manually hack the project.json file?

"frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  },

回答1:


That documentation where you can select the platform is from a previous beta or preview version of ASP.NET 5 so not valid anyone.

Your project.json looks correct.

DNX is an execution environment that can run on various underlying .NET frameworks, including .NET framework 4.5.1,4.5.2 or the latest .NET Framework 4.6.

.NET Core 5 is not .NET Framework 5 but is a modular runtime and library implementation that includes a subset of the .NET Framework 4.X. So you can call it mini .NET 4X. It is not the latest version of .NET framework for Windows. The latest version is .NET Framework 4.6

If you leave your project.json by default as

"frameworks": {
    "dnx451": { },
    "dnxcore50": { }
 },

then when you publish your project you'll then be able to publish to either .NET Core or .NET Framework.

clr-win = .NET Framework windows

core-clr-win = .NET Core

if you do not wish to create cross platform you can edit your project.json to

"frameworks": {
    "dnx451": { },
 },

and you'll not be able to see the Target DNC Version of .NET Core as a choice when you publish your site.

If you need to use a later .net version feature or if you you wish to include and reference a class library which itself targets a later .net framework version to your project you would need to change your project.json to target the same or later .net framework version e.g. dnx452 or dnx46

e.g.

 "frameworks": {
    "dnx46": { },
 },

As soon as you save the project.json file your project will automatically update itself. You can view the progress in the output window.



来源:https://stackoverflow.com/questions/33242352/targeting-runtime-for-new-mvc6-project-in-vs-2015

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