本文介绍了在 Visual Studio 中打开解决方案时如何自动运行 dotnet 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

解决方案

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

先决条件:

I am interested to run dotnet watch test when opening a solution with my unit tests in visual studio 2017. Is there a way to run that just after the solution is open without doing it manually?

解决方案

Visual Studio Task Runner can run any arbitrary CMD command when a project/solution is opened.

Prerequisites: Command Task Runner extention.

  1. Add Foo.cmd with a target command to your project having dotnet watch package installed. It could have one line of code:

    dotnet watch run
    

Make sure the file is properly encoded to UTF-8 without BOM.

  1. After Command Task Runner extention install, Add to Task Runner option should be accessible from context menu of *.cmd files. Press it and choose per-project level. As a result, commands.json should appear in the project.

  2. Go to VS View -> Other Windows -> Task Runner Explorer. Set up the binding for the Foo command in the context menu: Bindings -> Project Open (the window refresh could help to see a recently added command).

  3. Re-open the solution and check a command execution result in Task Runner Explorer.

How it could look:

这篇关于在 Visual Studio 中打开解决方案时如何自动运行 dotnet 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 18:42