【问题标题】:How to auto run a dotnet command when opening a solution in visual studio在 Visual Studio 中打开解决方案时如何自动运行 dotnet 命令
【发布时间】:2017-05-23 07:03:13
【问题描述】:

我有兴趣在 Visual Studio 2017 中使用我的单元测试打开解决方案时运行 dotnet watch test。有没有办法在打开解决方案后立即运行它而无需手动执行?

【问题讨论】:

标签: c# visual-studio .net-core visual-studio-2017


【解决方案1】:

Visual Studio Task Runner 可以在打开项目/解决方案时运行任意 CMD 命令。

先决条件:Command Task Runner 扩展。

  1. 将带有目标命令的Foo.cmd 添加到安装了dotnet watch 包的项目中。它可能只有一行代码:

    dotnet watch run
    

确保文件被正确编码为 UTF-8 而没有 BOM。

  1. Command Task Runner 扩展安装后,Add to Task Runner 选项应该可以从*.cmd 文件的上下文菜单中访问。按它并选择每个项目级别。因此,commands.json 应该会出现在项目中。

  2. 转到 VS View -> Other Windows -> Task Runner Explorer。在上下文菜单中为Foo 命令设置绑定:Bindings -> Project Open(窗口刷新有助于查看最近添加的命令)。

  3. 重新打开解决方案,查看Task Runner Explorer中的命令执行结果。

它的样子:

【讨论】:

    猜你喜欢
    • 2014-10-23
    • 2017-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-29
    • 1970-01-01
    • 2013-12-05
    相关资源
    最近更新 更多