2
votes

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

2

2 Answers

0
votes

I've seen behavior like this when the packages folder is checked in to source control. Remove the packages folder (ideally, ignore it via your NuGet.config's settings!) and let the build process restore the packages as appropriate.

You should also consider migrating to the new build system, as it is superior to the old XAML build system in most respects.

0
votes

I ended up adding the NUnitTestAdapter into a location on the build server that it can automatically be found and used. So then could remove it from the packages it gets from NuGet.

As described here

http://www.codewrecks.com/blog/index.php/2015/03/16/running-nunit-tests-in-a-tfs-2015-build-vnext/