zoukankan      html  css  js  c++  java
  • asp.net core 附加进程调试、指令等

    附加进程调试

    打开项目选择【调试-附加到进程】
    (.net framework 要附加到 w3wp.exe,.net core 要附加到 dotnet.exe)

    热更新版本bat

    @echo off
    chcp 65001
    # 先根据服务名称删除相关服务
    set rootPath=%~1
    set serviceName=%~2
    taskkill /F /T /FI "WINDOWTITLE eq %serviceName%" /IM dotnet.exe
    # 转到服务根目录
    cd /d %rootPath%
    
    echo ASPNETCORE_ENVIRONMENT=Development
    dotnet build      %默认Debug编辑模式./bin/Debug/%
    start "%serviceName%" dotnet watch run
    exit
    

    断点调试版本bat

    @echo off
    chcp 65001
    
    set rootPath=%~1
    set serviceName=%~2
    taskkill /F /T /FI "WINDOWTITLE eq %serviceName%" /IM dotnet.exe
    
    cd /d %rootPath%inDebug
    etcoreapp2.1
    start "%serviceName%" dotnet %serviceName%.dll
    

    发布版本bat

    @echo off
    chcp 65001
    
    set rootPath=%~1
    set serviceName=%~2
    set targetFramework=%~3
    taskkill /F /T /FI "WINDOWTITLE eq %serviceName%" /IM dotnet.exe
    
    set COMPILE_PATH=%rootPath%inRelease\%targetFramework%publish
    rd "%COMPILE_PATH%" /s/q
    cd /d %rootPath%
    dotnet publish -c Release
    

    Configuration

    静态读取

    var demo = this.Configuration.GetSection(nameof(Demo)).Get<Demo>();
    Console.WriteLine(demo.ToString());
    
    public void ConfigureServices(IServiceCollection services)
    {
        services.Configure<Demo>(this.Configuration.GetSection(nameof(Demo)));
    }
    

    动态配置

    public void ConfigureServices(IServiceCollection services)
    {
    	services.Configure<Demo>(binder=>
    	{
    		binder.Property1 = var1;
    		binder.Property2 = var2;
    	});
    }
    // inject
    public DemoController(IOptions<Demo> setting)
    {
        var demo = setting.Value;
    }
    

    写文件到指定目录

    写文件到指定目录

    合适的Exception

    ArgumentException
    ArgumentNullException
    NotImplementedException

  • 相关阅读:
    vue中computed和watch的区别,以及适用场景
    vue中使用过的全局API
    厦门中控
    设置圆角的弧度,保持兼容性
    伪元素::after和::before
    SpringMVC
    mui问题
    错误记录
    Android错误
    Android之界面(布局文件layput)
  • 原文地址:https://www.cnblogs.com/wesson2019-blog/p/13595138.html
Copyright © 2011-2022 走看看