I'm running some very simple unit tests in TFS 2015 using NUnit and the NUnit Test Adapter NuGet packages but the only way I can get the tests to pass is to restart the TFS service, then the project builds and tests pass once. The next time I run it I get the following error.
Build
(-1, 0)
Exception Message: Access to the path 'C:\Builds\2\RGDAgile\RGD.Common\src\RGD.Common\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll' is denied. (type UnauthorizedAccessException)
Exception Stack Trace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalDelete(String path, Boolean checkHost)
at System.IO.File.Delete(String path)
at Microsoft.TeamFoundation.Common.FileSpec.DeleteFile(String path, Boolean throwExceptionOnFailure)
at Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectoryInternal(String path)
at Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectoryInternal(String path)
at Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectoryInternal(String path)
at Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectoryInternal(String path)
at Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectoryInternal(String path)
at Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectory(String path, Boolean recursive, Boolean handleLongPaths)
at Microsoft.TeamFoundation.Build.Workflow.Activities.DeleteDirectory.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
It's as though the previous build is not releasing control of the dll so the next time the build is ran it can't clear the directory to pull the new code down.
Any help would be appreciated. I can't be the only person running NUnit on TFS 2015