Ted Nyberg Ted Nyberg - 1 year ago 201
ASP.NET (C#) Question

Unable to start Kestrel with 'dnx web', says "current runtime target framework is not compatible"

There are a lot of similar questions on SO, but I couldn't find a solution to my problem. It's evident I'm not familiar enough with .NET Core yet... )

I have a strict ASP.NET Core app, and I'm trying to start the Kestrel web server using the dnx web command, but it fails because it seems the active framework target is dnx451 (instead of dnxcore50).

My global.json looks like:

"projects": [ "FolderName", "src", "test" ], // What IS the actual project name?

"sdk": {
"version": "1.0.0-rc1-update2",
"runtime": "coreclr",
"architecture": "x86"

Excerpts from project.json:

"commands": {
"web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://*:8000/"

"frameworks": {
"dnxcore50": { }

Any finally, in launchSettings.json:

"profiles": {
"web": {
"commandName": "web",
"launchBrowser": false,
"launchUrl": "http://localhost:8000",
"environmentVariables": {
"Hosting:Environment": "Development"
"sdkVersion": "dnx-coreclr-win-x86.1.0.0-rc1-update2"

As far as I can see, the dependencies in project.json match the SDK version:

"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"

However, when I run dnx web I get the following:

System.InvalidOperationException: The current runtime target framework is not compatible with 'Okaymaker.Web'.
Current runtime target framework: 'DNX,Version=v4.5.1 (dnx451)'
Version: 1.0.0-rc1-16609
Type: Clr
Architecture: x86
OS Name: Windows
OS Version: 10.0
Runtime Id: win10-x86

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

Not sure why it says the current target framework is dnx451? I guess I can run dnx use before running dnx web, but I was under the impression that the config should handle the settings for me?

Here's what I see if I run dnvm list:

Active Version Runtime Architecture Location Alias
------ ------- ------- ------------ -------- -----
1.0.0-beta8 clr x64 C:\Users\TedNyberg\.dnx\runtimes
1.0.0-beta8 clr x86 C:\Users\TedNyberg\.dnx\runtimes
1.0.0-beta8 coreclr x64 C:\Users\TedNyberg\.dnx\runtimes
1.0.0-beta8 coreclr x86 C:\Users\TedNyberg\.dnx\runtimes
1.0.0-rc1-update1 clr x64 C:\Users\TedNyberg\.dnx\runtimes
1.0.0-rc1-update1 clr x86 C:\Users\TedNyberg\.dnx\runtimes
1.0.0-rc1-update1 coreclr x64 C:\Users\TedNyberg\.dnx\runtimes
1.0.0-rc1-update1 coreclr x86 C:\Users\TedNyberg\.dnx\runtimes
* 1.0.0-rc1-update2 clr x86 C:\Users\TedNyberg\.dnx\runtimes default
1.0.0-rc1-update2 coreclr x86 C:\Users\TedNyberg\.dnx\runtimes

Edit: Seems these problems can be resolved/avoided by installing Visual Studio 2015 Update 3 and the updated tooling for .NET Core, both available at: https://www.microsoft.com/net/core#windows

Answer Source

You have to use dnvm use to set the current runtime to coreclr. VisualStudio was not smart enough but the published scripts where smart enough to build a shell script to statically select the right engine.

This was a confirmed design flaw of RC1 (sorry for being to lazy to search the video notes from the ASP.NET Community Standup) and got fixed as part of the dotnet command line interface.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download