Visual Studio 2017 locking files

Viewed 6037

Visual Studio Version 15.2 (26430.6) Release.

Having recently updated to the above version I am running into continuous issues with VS locking up files when trying to build.

Could not copy "obj\Debug\projHype.dll" to "bin\Debug\projHype.dll". Exceeded retry count of 10. Failed.

Also tried running VS2017 with and with out admin priveledges

I tried the suggestions for older versions of visual studio but to no avail. Any ideas how to get around this?

3 Answers

While there may be other causes, testhost.exe and testhost.x86.exe can both result in a lock that prevents the build from completing. The symptoms are bewildering-- the test explorer churns indefinitely, sometimes timeout warnings appear in the build. Sometimes the files cannot be accessed even after VS is shut down.

If you are using nUnit or another test framework, make sure that test discovery does not encounter any infinite loops or crashes in your code. If this happens, it can hang the testhost executable. For example, if you use nUnit TestCase or TestCaseSource, if any of these perform an action that can hang, lock up, or crash, they will be invoked before the tests are executed.

This is the tricky bit-- your tests haven't run yet, but your code can lock up VS! While this may not be your problem, if you have unit test discovery in any way, check that it all completes.

One way to make sure all discovery completes is to use the functions from a test itself, and disable them as a TestCase or TestCaseSource (or equivalent in other test frameworks). If the test hangs or crashes, that's the culprit.

For me it helped to run the program again with accepting "run last successful build". After the run, the locks were gone.

Related