尝试在Linux上编译KestrelHttpServer

Kestrel是目前在非Windows平台上运行ASP.NET 5应用程序的唯一可用Web服务器,但微软似乎将它冷落在一边,源代码更新很慢。

今天试着在Linux上编译Kestrel的源代码,遇到了很多问题。在这篇博文中记录一下。

运行编译命令:

./build.sh

出错信息:

-bash: ./build.sh: Permission denied

修复方法:

chmod +x build.sh

再次编译,出错:

./build.sh: line 31: packages/KoreBuild/build/kvm.sh: No such file or directory
./build.sh: line 35: kvm: command not found

修复方法:在build.sh中删除以下的代码:

if ! type k > /dev/null 2>&1; then
    source packages/KoreBuild/build/kvm.sh
fi

if ! type k > /dev/null 2>&1; then
    kvm upgrade
fi

继续编译,出错:

Unable to locate xunit.runner.kre >= 1.0.0-*
Writing lock file /data/git/KestrelHttpServer/test/Microsoft.AspNet.Server.KestrelTests/project.lock.json
Restore complete, 192ms elapsed
Total time 1067ms
Errors in /data/git/KestrelHttpServer/test/Microsoft.AspNet.Server.KestrelTests/project.json
    Unable to locate xunit.runner.kre >= 1.0.0-*

修复方法:将 test/Microsoft.AspNet.Server.KestrelTests/project.json 文件中的 kre 改为 aspnet,vim 命令如下:

:%s/kre/aspnet/g 

继续编译,出现错误:

/data/git/KestrelHttpServer/src/Kestrel/ServerFactory.cs(1,24): error CS0234: The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?)
...

修复方法:修改 src/Kestrel/project.json 中的 frameworks 部分,修改为:

"frameworks": {
     "dnx451": { },
     "dnxcore50": { }
}

继续编译,出现新的错误:

src/Kestrel/ServerFactory.cs(4,27): error CS0234: The type or namespace name 'ConfigurationModel' does not exist in the namespace 'Microsoft.Framework' (are you missing an assembly reference?)

修复方法:在 src/Kestrel/project.json 中添加 Microsoft.Framework.ConfigurationModel 的引用

{
    "dependencies": {
"Microsoft.Framework.ConfigurationModel": "1.0.0-*"
} }

继续编译,出现新的错误:

src/Kestrel/ServerRequest.cs(1,24): error CS0234: The type or namespace name 'HttpFeature' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?)

修复方法:在 src/Kestrel/project.json 中添加 Microsoft.AspNet.HttpFeature 的引用

"Microsoft.AspNet.HttpFeature": "1.0.0-*"

但该修复方法无效,依然出现同样的错误。。。就卡在这,没找到解决方法。

于是,这次编译尝试 Kestrel 失败。

posted @ 2015-06-30 21:01  dudu  阅读(3790)  评论(8编辑  收藏  举报