1.打开visual studio code 创建一个项目 打开终端 输出: dotnet new web --name hellocore
2.用visual studio code打开项目文件夹 输入dotnet run 运行 打开浏览器

如果在Startup文件里修改输出(Hello World!11111),再去刷新浏览器,这里输出是不会变的,除非关掉调试再重新启动
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!11111");
});
}
}
core中有一个工具DotNetWatcherRun可以改变在运行中修改输出
在helloCore.csproj文件中添加:<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" />
<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp2.0</TargetFramework> </PropertyGroup> <ItemGroup> <Folder Include="wwwroot" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" /> <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" /> </ItemGroup> </Project>
然后在终端上使用命令 dotnet restore 手动更新包

输入dotnet watch run 运行

再去修改
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!22222");
});
}
保存 ,刷新页面
