简体   繁体   中英

How to auto run a dotnet command when opening a solution in visual studio

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

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:

在此处输入图片说明

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM