代码就是示例代码,原来根据流程,配置的好好的,忽然就不能用了web
症状以下:shell
dnx web Error: Unable to load application or execute command 'Microsoft.AspNet.Server.Kestrel'. Available commands: web.
经过dnu restore也无论用。查看一下运行环境吧(好像我尝试过升级dnvm update-self):json
dnvm ___ _ ___ ____ ___ / _ \/ |/ / | / / |/ / / // / /| |/ / /|_/ / /____/_/|_/ |___/_/ /_/ .NET Version Manager v1.0.0-rc2-15546 By Microsoft Open Technologies, Inc. usage: dnvm <command> [<arguments...>] dnvm list Active Version Runtime Architecture OperatingSystem Alias ------ ------- ------- ------------ --------------- ----- * 1.0.0-rc1-update1 clr x86 win default
一个是rc1,一个是rc2.因而先升级一下,dnvm upgrade,可是提示我是最新的,不须要升级。api
此时dnx build报错,没法加载依赖,app
dnu build Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16231 Building HelloWeb for DNX,Version=v4.5.1 Using Project dependency HelloWeb 1.0.0 Source: E:\asphome\samples\latest\HelloWeb\project.json Unable to resolve dependency Microsoft.AspNet.Server.Kestrel 1.0.0 Unable to resolve dependency Microsoft.AspNet.IISPlatformHandler 1.0.0 Unable to resolve dependency Microsoft.AspNet.Diagnostics 1.0.0 Unable to resolve dependency Microsoft.AspNet.Hosting 1.0.0 Unable to resolve dependency Microsoft.AspNet.StaticFiles 1.0.0 Unable to resolve dependency Microsoft.Extensions.Logging.Console 1.0.0 Using GlobalAssemblyCache dependency fx/mscorlib Source: C:\WINDOWS\Microsoft.NET\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll 下面还有好长的报错:
我去dnx的路径里查一下包的状况: .dnx\packages\Microsoft.AspNet.Server.Kestrelasp.net
更加确认是rc2引发的问题了。ui
后来搜索相关信息,发现这个命令:dnvm upgrade -u 就是升级到开发版本。Latest Unstablespa
dnvm upgrade -u Determining latest version Downloading dnx-clr-win-x86.1.0.0-rc2-16319 from https://www.myget.org/F/aspnetvnext/api/v2 Installing to C:\Users\shenj\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc2-16319 Adding C:\Users\shenj\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc2-16319\bin to process PATH Adding C:\Users\shenj\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc2-16319\bin to user PATH Updating alias 'default' to 'dnx-clr-win-x86.1.0.0-rc2-16319' dnvm list Active Version Runtime Architecture OperatingSystem Alias ------ ------- ------- ------------ --------------- ----- 1.0.0-rc1-update1 clr x86 win * 1.0.0-rc2-16319 clr x86 win default
此时切换到项目路径,直接dnx web,仍是失败。dnu restore以后,再运行,就成功了。
.net
总结:rest
我的认为这次缘由是asp.net5升级到rc2引发的,dnu restore时,下载了rc2的包,但运行是环境却升不了级,不匹配。
为何dnvm upgrade无论用呢?为何我运行环境没有升级到rc2时,都能restore出来rc2的包,这是一大疑问,是微软的问题吧!
我又想到,原来运行时,一直是1.0.0-rc1-final来着,不知道怎么变成1.0.0-rc1-update1了。dnu restore的包不匹配是否是由此引发的呢?
最后,我失望的发现,.dnx/packages里的程序包是多个版本同时存在的,它的体积到目前有1.25GB。比安装.net framework还要坑。
难道是我常常restore的错,不知道有没有清除的命令。