0

I have found there are a couple of situations that cause Visual Studio (2017 15.8.8) to hang up background processes such as VBCSCompilier and a conhost.exe. These are absolutely caused by errors I make, mostly anytime you have an error that deals with resources or locations (pages, js files etc) and it is not there, this will cause Visual Studio to hang up and not allow IIS to update when you restart VS because the background processes are still being used.

I have spent hours trying to figure out why my website is not updating and when I look at my Task Manager sure enough those processes are still running when VS is shutdown, kill those processes and everything works.

Is there a way possibly using PowerShell to look for running processes and kill them if they are still running? I do not have enough experience with PowerShell scripting to feel comfortable enough to try and mess with running processes and not sure if there is a better way to handle this or if there are other processes that should be restarted or possibly even something from Microsoft that already does this?

So far I have identified the following that need to be killed before restarting Visual Studio:

VBCSCompiler.exe
conhost.exe        <-- Only ones running under username not the MYSQL user
Andy Braham
  • 9,594
  • 4
  • 48
  • 56
  • How about [taskkill](https://stackoverflow.com/questions/8667221/batch-script-to-close-all-open-command-prompt-windows/8667368#8667368)? – rene Oct 27 '18 at 08:24
  • Are you sure it is caused by `VBCSCompiler.exe` specifically? It is by design: after exiting VS, that process will remain active for some time and then exit by itself. – George Chakhidze Oct 29 '18 at 12:38
  • @GeorgeChakhidze It looks like this is caused anytime there is a compiler failure and you attempt to start the app. This seems to cause both of the above to hang up in the background not releasing the resources. – Andy Braham Oct 30 '18 at 06:43

1 Answers1

1

You can use the get-process cmdlet with -IncludeUsername

get-process -IncludeUsername | Where-Object { $_.Username -eq "YourUser" -and $_.Name -eq "YourProcessName" } | stop-process
Peter Schneider
  • 2,879
  • 1
  • 14
  • 17