TFS 2015在上次成功构建之后无法删除NUnit测试dll

时间:2015-09-25 16:10:40

标签: tfs nunit

我使用NUnit和NUnit测试适配器NuGet包在TFS 2015中运行一些非常简单的单元测试,但我能够通过测试的唯一方法是重启TFS服务,然后项目构建和测试通过一次。下次我运行它时会出现以下错误。

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)

好像之前的版本没有释放对dll的控制权,所以下次运行构建时,它无法清除目录以拉下新代码。

任何帮助将不胜感激。我不能成为唯一一个在TFS 2015上运行NUnit的人

2 个答案:

答案 0 :(得分:0)

packages文件夹签入源代码管理时,我已经看到过这样的行为。删除packages文件夹(理想情况下,通过NuGet.config的设置忽略它!)并让构建过程根据需要恢复软件包。

您还应该考虑迁移到新的构建系统,因为它在大多数方面优于旧的XAML构建系统。

答案 1 :(得分:0)

我最终将NUnitTestAdapter添加到构建服务器上的一个位置,可以自动找到并使用它。那么就可以从它从NuGet获得的包中删除它。

如此处所述

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