312

Almost unconsciously I hit the keyboard build macro that builds my entire solution. This can happen just as I notice a code change. The build dominates my computer, and I basically have to wait till it finishes. 10 seconds!

How can I cancel a build?

Valamas
  • 24,169
  • 25
  • 107
  • 177

15 Answers15

538

You can hit Ctrl+Break on the keyboard to cancel/stop a build that is currently in progress.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Chris Subagio
  • 6,099
  • 1
  • 15
  • 7
  • When I tried it it seemed to depend on which pane within VS had focus (e.g. Solution Explorer vs Output pane) - but this might not be true – marnir Oct 17 '13 at 18:29
  • 90
    The break key can be labelled "pause" too – dyesdyes Nov 19 '13 at 10:59
  • 3
    That's Ctrl + Fn + F6 on your Dell Inspiron, if you have one. –  Feb 26 '14 at 04:19
  • 21
    If your keyboard doesn't have a Pause/Break key, you can go to Tools -> Options -> Keyboard then set an extra mapping for the Build.Cancel command. – Sean Colombo Jul 31 '15 at 18:32
  • "Project cannot cancel build at this time... Try again later." https://developercommunity.visualstudio.com/t/vs-build-is-stuck-cannot-cancel-the-build/329296 Can only kill task in Taskmanager... :( – The incredible Jan Aug 02 '22 at 12:39
194

Go to Visual Studio Build Menu -> cancel build , easy :)

enter image description here

Chuck D
  • 1,629
  • 2
  • 16
  • 32
darmis
  • 2,879
  • 1
  • 19
  • 21
  • 3
    You need to turn on Tools -> Settings -> Expert Settings for that to work. – CJ Dennis Feb 09 '17 at 00:35
  • 11
    To go fast, use `Alt + b + a` – Elliott Beach Feb 24 '19 at 15:29
  • 1
    @profimedica I think most people would like to use the keyboard perhaps Alt + b + a, also works. – darmis Mar 24 '19 at 15:16
  • @darmis, The answer marked (Ctrl+Break) did not worked for me. I was publishing to Azure, dotnet build finished but the build window continued to display output from the deploying process. I will try Alt + b + a and let you know – profimedica Mar 25 '19 at 16:31
  • What do you do if "Cancel" doesn't exist and "Alt + b + a" doesn't do anything? And what if you don't have an option for setting "Expert settings"? – xizwyck Apr 20 '22 at 14:31
20

This is crude, but it works well. The Visual Studio on one of my projects (I turn MVC view building on to catch markup errors), well, the project becomes unresponsive while building. I can't cancel the build using the keyboard shortcuts.

So I made this batch file that sits on my quick launch task bar.

@echo off
echo KILL BILLd
for /L %%i in (1,1,10) do (
   Taskkill /IM aspnet_compiler.exe /F
   timeout 1
)

I also made the batch file launch minimized. The build stops and Visual Studio just throws in the error window that there was a problem building.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Valamas
  • 24,169
  • 25
  • 107
  • 177
11

If all else fails go to task manager and kill the msbuild task under Visual Studio 2017

Adam Seabridge
  • 1,909
  • 1
  • 20
  • 27
8

Ctrl + Break works, but only if the Build window is active. Also, interrupting the build will sometimes leave a corrupted .obj file that will have to be manually deleted in order for the build to proceed.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mark Holten
  • 131
  • 1
  • 4
3

Ctrl + End works for me on Visual C++ 2010 Express.

kgsmith
  • 31
  • 1
3

Visual Studio 2015 Professional Update 3

If you are using Mac you can do following

Click Build --> Cancel from the Visual Studio Menu

or

Select Azure App Service Activity window --> Cancel it will cancel the publish activity.

2

I'm using Visual Studio 2015. To stop build you can follow:

  1. Ctrl + Pause
  2. Ctrl + Break
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Thanh
  • 39
  • 2
2

The "pause" command was a function button underneath my right shift key, so the below combination of keys did the trick for me.

Ctrl + Fn + Shift

Isaac Adams
  • 150
  • 4
2

I was hit by an unresponsive build and absolutely nothing would allow me to either kill or cancel the build. Even trying to end the task would trigger a user input window, saying that it could not be ended while the build is still going on (quite ironic because that was precisely the intention, to leave that broken state).

The build was taken care of by MSBuild, so the one way I found is to end its task. When forcing MSBuild.exe to end, VS will wake up and finally see the build as cancelled, allowing you to work again.

Hope this helps someone in the same situation.

Frederik.L
  • 5,522
  • 2
  • 29
  • 41
1

The build context menu has a Cancel build in Visual Studio 2013.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
jacobsgriffith
  • 1,448
  • 13
  • 18
1

Go to the Window menu and choose "Web Publish Activity" There will be a cancel button. Cancel button on "Web Publish Activity" tab

Community
  • 1
  • 1
Ray Koren
  • 814
  • 14
  • 25
1

For users of Lenovo Thinkpad T470s like me, you can simulate the break key by hitting Ctrl+Fn+P, which cancels the build.

Skeird
  • 173
  • 2
  • 10
1

If you do not have a break key on your keyboard, you can change the keyboard shortcut to cancel the build.

Just search hotkeys in the search menu. This should take you to Environment > Keyboard. From there, search for Build.Cancel and you can change it to whatever keyboard shortcut ( eg. Ctrl+Alt+End ). This is a good keyboard shortcut because it won't conflict with other uses of Ctrl+End or Ctrl+Shift+End .

trinalbadger587
  • 1,905
  • 1
  • 18
  • 36
0

Ctrl + Shift + Pause/Break

I am using Visual Studio Community 2022

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
MCS
  • 1