Restart Tridion services in Visual Studion pre-build and post-build events. See https://gist.github.com/jhorsman/6931759 for PowerShell scripts. Run the post-build event always to start services after a failed build.
powershell -file "$(SolutionDir)tools\Tridion-services-stop.ps1"
powershell -file "$(SolutionDir)tools\Tridion-services-start.ps1"