ASP.NET核心 - 在Visual Studio 2015中通​​过Docker进行调试时出现的问题 [英] ASP.NET Core - Issues while Debugging through Docker in Visual Studio 2015

查看:171
本文介绍了ASP.NET核心 - 在Visual Studio 2015中通​​过Docker进行调试时出现的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio中使用Docker在ASP.NET Core上运行我的应用程序时面临的问题。我的应用程序只使用 dnxcore50 框架。我的project.json文件是:

  {
version:1.0.0- *,
compilationOptions:{
emitEntryPoint:true
},
dependencies:{
Microsoft.AspNet.IISPlatformHandler:1.0.0-rc1-
Microsoft.AspNet.Mvc:6.0.0-rc1-final,
Microsoft.AspNet.Server.Kestrel:1.0.0-rc1-final,
Microsoft.AspNet.StaticFiles:1.0.0-rc1-final
},
框架:{
dnxcore50:{}
} ,
exclude:[
wwwroot,
node_modules
],
publishExclude:[
**。 ,
**。vspscc
],
命令:{
web:Microsoft.AspNet.Server.Kestrel
}

我尝试过以下方法:


  1. 当我的dnvm指向运行时 dnx-coreclr-win-x64.1.0.0-rc1-update1 时,如下图所示。

我的应用程序生成成功。但是,在Docker上运行/调试应用程序时遇到以下错误,我的应用程序停留在打开站点



错误详细信息:
当前运行时框架与'app'不兼容
当前的运行时目标框架:'DNX,Version = v4.5.1(dnx451)'
请确保运行时与指定的框架匹配在project.json中


  1. 由于上述错误消息表明框架不匹配,我更改了默认和活动运行时通过修改默认别名并执行命令 dnvm使用default -p dnx-coreclr-linux-x64.1.0.0-rc1-update1 。然后,我重新启动VS(确保更改在VS中可见)



但是,我的应用程序仍然建立在DNX版本v4.5.1上,如下面的构建日志中所建议的:

  1>信息:[LoaderContainer]:Load name = Microsoft.Dnx.Tooling 
1>信息:[PathBasedAssemblyLoader]:加载的名称= Microsoft.Dnx.Tooling在2ms
1>信息:[Bootstrapper]运行时框架:DNX,Version = v4.5.1
1> Microsoft .NET开发实用程序Mono-x64-1.0.0-rc1-16231

因此,应用程序再次无法运行与第1点相同的错误。



另外,在更改默认运行时,dnu restore停止从命令行工作,并提供以下错误:


'dnu'不被识别为内部或外部命令,可操作的
程序或批处理文件。


有趣的是,'dnu'恢复命令从VS继续工作(如VS构建日志中所建议的)。



< ol start =3>
  • 然后,我尝试将dnvm运行时更改为 dnx-mono.1.0.0-rc1-update1 。但是它失败并出现以下错误:




  • 找不到dnx-mono.1.0.0-rc1-update1 .1.0.0-rc1-update1,你需要
    运行'dnvm install
    default'吗?
    在C:\Program Files\Microsoft DNX\Dnvm\dnvm.ps1:1659 char:9
    + throw找不到$ runtimeFullName,你需要运行'$ Com .. 。
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ b $ b + FullyQualifiedErrorId:找不到dnx-mono.1.0.0-rc1-update1.1.0.0-rc1-update1,你要运行'dnvm install default'吗?


    我需要使用什么运行时,从VS运行docker,如何更改?请求帮助解决问题。



    更新
    我终于可以通过将docker文件第一行更改为 FROM microsoft / aspnet:1.0.0- rc1-update1-coreclr FROM microsoft / aspnet:1.0.0-rc1-update1 。 tt的提示。

    解决方案

    你的dockerfile的第一行是什么?
    应该为CoreClr的FROM microsoft / aspnet:1.0.0-rc1-update1-coreclr


    I'm facing issues while running my application built on ASP.NET Core using Docker in Visual Studio. My application only uses dnxcore50 framework. My project.json file is:

    {
      "version": "1.0.0-*",
      "compilationOptions": {
        "emitEntryPoint": true
      },
      "dependencies": {
        "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
        "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
        "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
        "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final"
      },
      "frameworks": {
        "dnxcore50": { }
      },
      "exclude": [
        "wwwroot",
        "node_modules"
      ],
      "publishExclude": [
        "**.user",
        "**.vspscc"
      ],
      "commands": {
        "web": "Microsoft.AspNet.Server.Kestrel"
      }
    }
    

    I have tried following approaches:

    1. When my dnvm points to runtime dnx-coreclr-win-x64.1.0.0-rc1-update1 as shown in figure below.

    My application builds successfully. But, I get following error on running/debugging the application on docker and my application gets stuck at "Opening site http://192.168.99.100:5000"

    Error details: The Current runtime framework is not compatible with 'app' The current runtime target framework: 'DNX,Version=v4.5.1 (dnx451)' Please make sure the runtime matches the framework specified in project.json

    1. As the above error message suggests there is mismatch in framework, I changed the default and active runtime to dnx-coreclr-linux-x64.1.0.0-rc1-update1 by modifying default alias and executing command dnvm use default -p. Then, I restart my VS (to make sure the changes are visible in VS).

    However, my application still builds on DNX version v4.5.1 as suggested in the build logs below:

    1>  Information: [LoaderContainer]: Load name=Microsoft.Dnx.Tooling
    1>  Information: [PathBasedAssemblyLoader]: Loaded name=Microsoft.Dnx.Tooling in 2ms
    1>  Information: [Bootstrapper] Runtime Framework: DNX,Version=v4.5.1
    1>  Microsoft .NET Development Utility Mono-x64-1.0.0-rc1-16231
    

    Hence, the application again fails to run with the same error as in point 1.

    Additionally, on changing the default runtime dnu restore stops working from command line and gives with following error:

    'dnu' is not recognized as an internal or external command, operable program or batch file.

    Interestingly, the 'dnu' restore command continues to work from VS (as suggested in VS build logs).

    1. I then tried to change dnvm runtime to dnx-mono.1.0.0-rc1-update1. But it fails with following error:

    Cannot find dnx-mono.1.0.0-rc1-update1.1.0.0-rc1-update1, do you need to run 'dnvm install default'? At C:\Program Files\Microsoft DNX\Dnvm\dnvm.ps1:1659 char:9 + throw "Cannot find $runtimeFullName, do you need to run '$Com ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (Cannot find dnx...stall default'?:String) [], Run timeException + FullyQualifiedErrorId : Cannot find dnx-mono.1.0.0-rc1-update1.1.0.0-rc1-update1, do you nee d to run 'dnvm install default'?

    What runtime I need to use to run docker from VS and how I can change it? Request your help to resolve the issue.

    Update I was finally able to resolve the issue by changing the docker file first line to FROM microsoft/aspnet:1.0.0-rc1-update1-coreclr FROM microsoft/aspnet:1.0.0-rc1-update1. Thanks @bertt for the tip.

    解决方案

    what's in the first line of your dockerfile? should be 'FROM microsoft/aspnet:1.0.0-rc1-update1-coreclr' for CoreClr

    这篇关于ASP.NET核心 - 在Visual Studio 2015中通​​过Docker进行调试时出现的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆