.NET 的開源,有了更多的DIY樂趣。這篇博文記錄一下在新安裝的 Linux Ubuntu 14.04 上通過自己動手編譯 dotnet cli 的源代碼生成 .net core sdk 的 deb 安裝包。
1)安裝一個現有版本的 .net core sdk
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893 sudo apt-get update apt-get install dotnet-dev-1.0.0-preview2.1-003177
如果不安裝,build時會出現下面的錯誤
dotnet_install: Error: Unable to locate libunwind. Install libunwind to continue dotnet_install: Error: Unable to locate libicu. Install libicu to continue
2)從 github 上簽出 dotnet cli 的源代碼
apt-get install git git clone https://github.com/dotnet/cli.git
3)安裝依賴組件 liblldb, devscripts, debhelper
apt-get install liblldb-3.6 apt-get install devscripts apt-get install debhelper apt-get install curl
4)運行 build 命令
./build.sh /t:compile
5)build 成功后的輸出結果
~/cli/artifacts/ubuntu.14.04-x64/packages# ls
dotnet-host-ubuntu-x64.1.0.1.deb
dotnet-hostfxr-ubuntu-x64.1.0.1.deb
dotnet-sharedframework-ubuntu-x64.1.0.1.deb
注:在 build 時可通過 init-microsoft.dotnet.buildtools.log 日志文件查看 build 進度。