安裝.NET Core
->首先需要刪除以前安裝的版本
-> 獲取安裝腳本
curl -sSL https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-preview1/scripts/obtain/dotnet-install.sh | bash /dev/stdin --version 1.0.0-preview1-002702 --install-dir ~/dotnet
注:在CentOS中要安裝.net core環境需要libunwind和libicu庫,所以要先安裝好這兩個運行庫,否則會報錯:
dotnet_install: Error: Unable to locate libunwind. Install libunwind to continue
dotnet_install: Error: Unable to locate libicu. Install libicu to continue
yum install libunwind yum install libicu
-> 安裝完.net core后我們需要配置一個快捷方式,也可以配置環境變量,否則CentOS不認識dotnet命令
sudo ln -s ~/dotnet/dotnet /usr/local/bin
到這里CentOS的.NET Core環境安裝完畢!
測試運行環境
-> 新建一個.Net項目
#創建項目文件夾 mkdir myfirstdotnetcoreapp cd myfirstdotnetcoreapp #創建項目 dotnet new #編譯 dotnet restore #運行 dotnet run
運行成功后打印:
Project myfirstdotnetapp (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
Hello World!