0

I have a DNXCore5 application that I've been very careful about only targeting DNXCore. Anyway I can publish it to Windows Server 2012 R2 fine with a very small amount of steps. I'm trying to do the same in Ubuntu. I've set up my environment and have copied over my published project, I'm using Kestrel as the web server so it's identical on Windows as it is Linux.

I've already setup dnvm and have beta 5 of the runtime installed fine. I then mark the kestrel script that Visual Studio created as executable, via,

chmod +x kestrel

Now I can't run the kestrel script as it is as the last line fails, due to it trying to launch a local copy of dnx that isn't there (for some reason).

exec "$DIR/approot/runtimes/dnx-coreclr-win-x64.1.0.0-beta5/bin/dnx" --appbase "$DNX_APPBASE" Microsoft.Framework.ApplicationHost kestrel "$@"

So I modify the last line so that it reads,

dnx --appbase "$DNX_APPBASE" Microsoft.Framework.ApplicationHost kestrel "$@"

Typing just dnx on its own shows that it's using the correct framework, as I get the following output,


Microsoft .NET Execution environment Mono-x64-1.0.0-beta5-12103

Usage: dnx [options]

Options:
  --appbase <PATH>                 Application base directory path
  --lib <LIB_PATHS>                Paths used for library look-up
  --debug                          Waits for the debugger to attach before beginning execution.
  -?|-h|--help                     Show help information
  --version                        Show version information
  --watch                          Watch file changes
  --packages <PACKAGE_DIR>         Directory containing packages
  --configuration <CONFIGURATION>  The configuration to run under
  --port <PORT>                    The port to the compilation server

Now when I launch the kestrel script via ./kestrel, I get,


System.InvalidOperationException: The current runtime target framework is not compatible with 'MyApp'.

Current runtime Target Framework: 'DNX,Version=v4.5.1 (dnx451)'
  Type: Mono
  Architecture: x64
  Version: 1.0.0-beta5-12103

Please make sure the runtime matches a framework specified in project.json
  at Microsoft.Framework.ApplicationHost.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
  at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0
  at dnx.host.Bootstrapper.RunAsync (System.Collections.Generic.List`1 args, IRuntimeEnvironment env) [0x00000] in <filename unknown>:0

I'm struggling to find anyone who knows how to get rid of this error, I'm not targeting the full framework, if I open up the references node in visual studio solution explorer for my projects (web app, and class library), they both only have a single node for "DNX Core 5.0", plus they are both targeting it in the propject properties section. I have no idea where it is supposedly getting this refernce from. My project.json documents are as follows,


Lib

  "dependencies": {
  },

  "frameworks": {
    "dnxcore5": {
      "dependencies": {
        "System.Collections": "4.0.10-beta-23019",
        "System.Runtime": "4.0.20-beta-23019",
        "Microsoft.CSharp": "4.0.0-beta-23019"
      }
    }
  }

Web App

  "dependencies": {
    "Microsoft.Framework.ConfigurationModel": "1.0.0-beta5",
    "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta5",
    "Microsoft.AspNet.Mvc": "6.0.0-beta5",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
    "Microsoft.Framework.Logging": "1.0.0-beta5",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta5",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta5",
    "Newtonsoft.Json": "7.0.1",
    "Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta5",
    "System.Security.Cryptography.DeriveBytes": "4.0.0-beta-23019",
    "MyLib": "1.0.0-*",
    "Kestrel":  "1.0.0-beta5"
  },

  "frameworks": {
    "dnxcore5": {
      "dependencies": {
        "System.Runtime.Extensions": "4.0.10-beta-23019",
        "System.Collections": "4.0.10-beta-23019",
        "System.Runtime": "4.0.20-beta-23019",
        "Microsoft.CSharp": "4.0.0-beta-23019",
        "System.Private.Networking": "4.0.0-beta-23109",
        "System.Net.Security": "4.0.0-beta-23109"
      }
    }
  },

I've even made sure I'm just using Kerstrel for hosting. Any ideas? I'm totally stuck.

DavidG
  • 113,891
  • 12
  • 217
  • 223
Nick
  • 1,015
  • 12
  • 31
  • I *think* it might have something to do with Newtonsoft.JSON, as it's not actually a vnext library, or so it seems. I might be totally wrong in saying that. – Nick Aug 14 '15 at 13:53
  • In your script - dnx-coreclr-win-x64 - refers to a folder containing runtime for 64-bit Windows - you can't expect this will run on non-windows (or even on 32-bit windows). Your application seems to be originally targeting CoreClr and you try running it with Mono which is treated as .NET Framework - probably this is the source of the mismatch – Pawel Aug 15 '15 at 19:17
  • Okay, if that's the case, why is Visual Studio creating this? Why is it creating a bash script for Linux that has no way of working? Plus as mentioned above I have modified that line of the script so that it just calls dnx, which is on the system and functioning as expected. – Nick Aug 17 '15 at 07:33

0 Answers0