自动化/执行多个 ASP.NET Core 命令 [英] Automate/Execute multiple ASP.NET Core commands

查看:32
本文介绍了自动化/执行多个 ASP.NET Core 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Visual Studio Code 中自动化/执行多个 ASP.NET Core 命令?

How to automate/execute multiple ASP.NET Core commands in Visual Studio Code?

例如,一次执行dotnet cleandotnet restoredotnet 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 restoredotnet 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)

现在,通过输入 cbrrrp> 将在 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 ************

输入cbcrbcrbrcrbprbp会执行他们各自的多命令.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆