【问题标题】:Automate/Execute multiple ASP.NET Core commands自动化/执行多个 ASP.NET Core 命令
【发布时间】:2017-11-24 11:53:29
【问题描述】:

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

例如,一次性执行dotnet cleandotnet restoredotnet build等..


我本来想问这个问题,但找到了解决方案。所以与社区分享。

【问题讨论】:

  • 在分享自己的学习时,请尝试提取问题并回答自己的问题。

标签: visual-studio-code .net-core


【解决方案1】:

如果您使用 Visual Studio Code 开发 ASP.NET Core 应用程序,您可以在 doskey 的帮助下使用简短的命令自动执行 dotnet restoredotnet builddotnet rundotnet 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)

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

输入cbcrbcrbrcrbprbp 将执行各自的多命令。


这些快捷方式会在 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
],

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-07
    • 2020-09-04
    • 2012-08-25
    • 1970-01-01
    • 2018-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多