如果您使用 Visual Studio Code 开发 ASP.NET Core 应用程序,您可以在 doskey 的帮助下使用简短的命令自动执行 dotnet restore、dotnet build、dotnet run、dotnet clean 命令。
doskey c = dotnet clean
doskey b = dotnet build
doskey r = dotnet restore
doskey rr = dotnet run
doskey p = dotnet publish -c release -r centos.7-x64 (NOTE: Here centos is the target OS)
现在,通过输入 c、b、r、rr 或 p 将在 Visual Studio Code 的集成终端窗口上执行各自的命令。您可以使用$T 将多个命令绑定在一起。例如:
doskey cb = dotnet clean $T dotnet build $T echo ************ DONE ************
doskey crb = dotnet clean $T dotnet restore $T dotnet build $T echo ************ DONE ************
doskey crbr = dotnet clean $T dotnet restore $T dotnet build $T dotnet run $T echo ************ DONE ************
doskey crbp = dotnet clean $T dotnet restore $T dotnet build $T dotnet publish - c release -r centos.7-x64 $T echo ************ DONE ************
doskey cbp = dotnet clean $T dotnet build $T dotnet publish -c release -r centos.7-x64 $T echo ************ DONE ************
输入cb、crb、crbr、crbp 或rbp 将执行各自的多命令。
这些快捷方式会在 Visual Studio Code 重新启动时消失,因此为了保持它们持久性,请将这些命令保存为批处理文件(例如:doskey.bat ),然后在 Visual Studio Code 中打开您的 usersettings.json 文件并添加这些行(这些设置用于命令提示符作为终端窗口):
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/K C:\\Users\\Username\\Desktop\\doskey.bat"
// replace the path with your batch file, also remember to keep the "/K" flag
],