DNX: The current runtime target framework is not c

2019-06-14 22:58发布

问题:

I am getting the following run-time error:

[InvalidOperationException: The current runtime target framework is not compatible with 'TestDeployProject'.

Current runtime Target Framework: 'DNX,Version=v4.5 (dnx45)'
  Type: CLR
  Architecture: x86
  Version: 1.0.0-beta6-12256

Please make sure the runtime matches a framework specified in project.json]

Project settings DNX SDK version:

project.json target frameworks:

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

DNVM list:

Active Version     Runtime Architecture OperatingSystem Alias
------ -------     ------- ------------ --------------- -----
       1.0.0-beta6 clr     x64          win
  *    1.0.0-beta6 clr     x86          win             latest
       1.0.0-beta6 coreclr x64          win             default

What could be the problem?

EDIT:

I have tried to use dnx451 as specified in this post. Same problem. The environmental variable also did not help.

回答1:

Look at the dependencies section in your project.json. You will get this error if your ASP.NET packages are not at beta6.

"dependencies": { "Microsoft.AspNet.Mvc": "6.0.0-beta6", "Microsoft.AspNet.Server.IIS": "1.0.0-beta6", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta6", "Microsoft.AspNet.StaticFiles": "1.0.0-beta6", "Microsoft.AspNet.Mvc.Core": "6.0.0-beta6", "Microsoft.AspNet.Cors": "1.0.0-beta6", "Microsoft.Framework.Configuration": "1.0.0-beta6", "Microsoft.Framework.Configuration.Json": "1.0.0-*", ...

Yesterday I upgraded two projects from beta4 to beta6. Accidentally left the dependencies of one at beta4, but with global.json sdk set to beta6, and I got this exact error when running it.