自动化/执行多个 ASP.NET Core 命令 [英] Automate/Execute multiple ASP.NET Core commands
问题描述
如何在 Visual Studio Code 中自动化/执行多个 ASP.NET Core 命令?
How to automate/execute multiple ASP.NET Core commands in Visual Studio Code?
例如,一次执行dotnet clean
、dotnet restore
、dotnet build
等..
For example, execute dotnet clean
,dotnet restore
, dotnet build
etc in a single go..
我正要问这个问题,但找到了解决方案.所以与社区分享这个.
I was going to ask this question but instead found a solution for the same. So sharing this with the community.
推荐答案
如果您使用 Visual Studio Code 开发 ASP.NET Core 应用程序,您可以自动执行 dotnet restore
、dotnet build
, dotnet run
, dotnet clean
命令在 doskey
的帮助下使用简短的命令.
If you are using Visual Studio Code to develop ASP.NET Core apps you can automate dotnet restore
, dotnet build
, dotnet run
, dotnet clean
commands using a short one with the help of doskey
.
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
将多个命令绑定在一起.例如:
Now, by entering c
, b
, r
, rr
or p
will execute their respective command(s) on the integrated terminal window of Visual Studio Code. You can bind multiple commands together using $T
. For eg:
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
会执行他们各自的多命令.
Entering cb
, crb
, crbr
, crbp
or rbp
will execute their respective multi-command(s).
这些快捷方式将在 Visual Studio Code 重新启动时清除,因此为了保持它们持久性,请将这些命令保存为批处理文件(例如:doskey.bat),然后在 Visual Studio Code 中打开 usersettings.json
文件并添加这些行(这些设置用于命令提示符作为终端窗口):>
These shortcuts will flush away when Visual Studio Code is restarted so to keep them persistent, save these commands as a batch file(eg: doskey.bat), and then open your usersettings.json
file in Visual Studio Code and add these lines (these settings are for Command Prompt as terminal window) :
"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
],
这篇关于自动化/执行多个 ASP.NET Core 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!