zoukankan      html  css  js  c++  java
  • asp.net core-12.dotnet watch run 和attach到进程调试

    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");
                });
            }
    

      保存 ,刷新页面

  • 相关阅读:
    JS站点
    1011 World Cup Betting (20分)
    1007 Maximum Subsequence Sum (25分)(动态规划DP)
    1006 Sign In and Sign Out (25分)
    1005 Spell It Right (20分)
    1004 Counting Leaves (30分)(DFS)
    1003 Emergency (25分)(Dijkstra算法)
    1002 A+B for Polynomials (25分)
    1001 A+B Format (20分)
    canvas
  • 原文地址:https://www.cnblogs.com/MingQiu/p/8227644.html
Copyright © 2011-2022 走看看