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

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

问题描述

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

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

例如,执行 dotnet clean dotnet restore dotnet构建等。

I打算问这个问题,但相反找到了解决方案。因此,请与社区共享。

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恢复 dotnet构建 dotnet运行 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时,这些快捷方式将消失,因此要使其保持持久性,请将这些命令批量保存F ile(例如: 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天全站免登陆