前置条件 ubuntu已安装.net core运行环境
分6步
mkdir netcore 创建一个项目文件夹
cd netcore 进入该文件夹
dotnet new new命令 用于创建一个新的控制台应用程序
dotnet restore 分析 project.json 文件, 下载依赖并返回结果
dotnet build 编译项目
dotnet run 运行项目
[email protected]:~/firstnetcore# mkdir netcore
[email protected]:~/firstnetcore# cd netcore
[email protected]:~/firstnetcore/netcore# dotnet new
Created new C# project in /root/firstnetcore/netcore.
[email protected]:~/firstnetcore/netcore# ls
Program.cs project.json
[email protected]:~/firstnetcore/netcore# dotnet restore
log : Restoring packages for /root/firstnetcore/netcore/project.json...
log : Writing lock file to disk. Path: /root/firstnetcore/netcore/project.lock.json
log : /root/firstnetcore/netcore/project.json
log : Restore completed in 2336ms.
[email protected]:~/firstnetcore/netcore# dotnet build
Project netcore (.NETCoreApp,Version=v1.0) will be compiled because expected outputs are missing
Compiling netcore for .NETCoreApp,Version=v1.0
Compilation succeeded.
0 Warning(s)
0 Error(s)
Time elapsed 00:00:00.8093903
[email protected]:~/firstnetcore/netcore# dotnet run
Project netcore (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
Hello World!
[email protected]:~/firstnetcore/netcore#
运行效果