Search code examples
c#asp.netasp.net-corednxdotnet-cli

Unable to publish .NET Core app (unsupported runtime)


I'm building an API using .net core, and I've just run into this issue during publishing:

The project being published does not support the runtime 'dnx-clr-win-x86.1.0.0-rc2-20221'

I saw this github issue as well as this one and I am no closer to a solution. Here is my updated project.json file:

  {
  "compilationOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "dependencies": {
    "AspNet.Security.OAuth.Validation": "1.0.0-alpha1-*",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Hosting": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-*",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-*",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-*",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-*",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-*",
    "OpenIddict.Core": "1.0.0-*",
    "OpenIddict.EF": "1.0.0-*"
  },

  "frameworks": {
    "net451": {
      "frameworkAssemblies": {
        "System.ComponentModel": { "type": "build" }
      }
    },

    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0-rc2-*"
        }
      },

      "imports": [
        "dnxcore50",
        "portable-net451+win8"
      ]
    }
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-rc2-*",
      "imports": "portable-net45+wp80+win8+wpa81+dnxcore50"
    }
  },

  "scripts": {
    "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],

  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}

I read somewhere that it could be due to the organisation of my dependencies?

UPDATE

This is the error I get when using dotnet restore:

Errors in c:\Users\Dude\Documents\my-api-v1\src\MyApi\obj\060296a3-1ddd-4410-9e77-9510cd667f39\bin\project.json
Microsoft.AspNetCore.Server.IISIntegration.Tools 1.0.0-rc2-20832 is not compatible with DNXCore,Version=v5.0.
Some packages are not compatible with DNXCore,Version=v5.0.
Microsoft.AspNetCore.Server.IISIntegration.Tools 1.0.0-rc2-20832 is not compatible with DNXCore,Version=v5.0 (win7-x64).
Some packages are not compatible with DNXCore,Version=v5.0 (win7-x64).

Solution

  • You're referencing ASP.NET Core RC2 packages that are incompatible with the VS RC1 tooling, as they both rely on totally different stacks (DNX vs .NET CLI).

    Instead, you should consider using dotnet publish.

    I'd recommend updating your project.json file to remove the obsolete commands section and to include the missing tools/scripts:

    "tools": {
      "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
        "version": "1.0.0-rc2-*",
        "imports": "portable-net45+wp80+win8+wpa81+dnxcore50"
      }
    },
    
    "scripts": {
      "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
    }
    

    netstandardapp1.5 should also be replaced by the new netcoreapp1.0 TFM and the following dependency should be added under netcoreapp1.0/dependencies:

    "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0-rc2-*" }
    

    You can take a look at https://github.com/openiddict/openiddict-core/blob/dev/samples/Mvc.Server/project.json for a working example.