标签:
目录
其实本篇上个月已经写好,
只是
但是,不忘初心方得始终
Learn .NET Core
http://asp.net/core
Down .NET Core
https://www.microsoft.com/net/core
Doc .NET Core
https://docs.asp.net/en/latest/getting-started.html
mkdir hwapp --创建目录hwapp
cd hwapp --打开目录hwapp
dotnet new --创建项目(Program.cs + project.json)
dotnet restore --还原依赖(project.lock.json)
dotnet build --编译项目(obj文件夹 和 bin文件夹)
dotnet run --运行项目(执行bin\debug\projectName.dll)
dotnet -h 查看帮助
命令行运行Hello World
cmd
上面需要配置的是launch.json中的program
"program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",
改成以下方式即可
"program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/programName.dll",
需要注意的是,配完这些按下F5还是不一定管用,确认c# debug是否装完
vs code 右下角状态栏会有提示
也可手动安装csharp扩展
Ctrl + P: ext install csharp
按照完csharp扩展,F5即可运行程序.
Ctrl + Shift + Y(调试控制台):
尝完Console版,再来体验一把Web版的
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final"
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; namespace ConsoleApplication { public class Startup { public void Configure(IApplicationBuilder app) { app.Run(context => { return context.Response.WriteAsync("Hello from ASP.NET Core!"); }); } } }
public static void Main(string[] args) { Console.WriteLine("Hello World!"); //using Microsoft.AspNetCore.Hosting;
var host = new WebHostBuilder() .UseKestrel() .UseStartup<Startup>() .Build(); host.Run(); }
缺点:
优点:
[Core] .Net Core之路(1) Hello World
标签:
原文地址:http://www.cnblogs.com/neverc/p/5610485.html