c# – TFS Build失败,“无法访问文件* FakeTypesCache”
几天以来,我们遇到了TFS构建问题.我们使用Microsoft Shims / Fakes进行一些单元测试,到目前为止我们没有遇到任何问题.
但最近UnitTest Step因以下错误而失败: 每隔一段时间就会发生以下情况: 2016-07-01T06:40:25.3532321Z ##[error]Error: System.IO.IOException: The process cannot access the file 'D:BuildsAgent87a4a39e...binDebugmscorlib.4.0.0.0.Fakes.FakedTypesCache' because it is being used by another process. 2016-07-01T06:40:25.3532321Z ##[error] at System.IO.__Error.WinIOError(Int32 errorCode,String maybeFullPath) 2016-07-01T06:40:25.3532321Z ##[error] at System.IO.FileStream.Init(String path,FileMode mode,FileAccess access,Int32 rights,Boolean useRights,FileShare share,Int32 bufferSize,FileOptions options,SECURITY_ATTRIBUTES secAttrs,String msgPath,Boolean bFromProxy,Boolean useLongPath,Boolean checkHost) 2016-07-01T06:40:25.3532321Z ##[error] at System.IO.FileStream..ctor(String path,Boolean checkHost) 2016-07-01T06:40:25.3532321Z ##[error] at System.IO.StreamReader..ctor(String path,Encoding encoding,Boolean detectEncodingFromByteOrderMarks,Boolean checkHost) 2016-07-01T06:40:25.3532321Z ##[error] at System.IO.StreamReader..ctor(String path) 2016-07-01T06:40:25.3532321Z ##[error] at Microsoft.VisualStudio.TraceCollector.FakesAssemblyReflector.LoadShimTypesFromCache(String fakedTypesCacheFilePath) 2016-07-01T06:40:25.3532321Z ##[error] at Microsoft.VisualStudio.TraceCollector.FakesAssemblyReflector.ReflectShimTypes(String fakesAssemblyFullPath) 2016-07-01T06:40:25.3532321Z ##[error] at Microsoft.VisualStudio.TraceCollector.UnitTestIsolationDataCollector.PopulateCollectionPlan(_CollectionPlan plan,XmlElement settings) 2016-07-01T06:40:25.3532321Z ##[error] at Microsoft.VisualStudio.TraceCollector.UnitTestIsolationDataCollector.OnSecondCollectorToInitialize(_CollectionPlan plan,XmlElement configurationElement) 2016-07-01T06:40:25.3532321Z ##[error] at Microsoft.VisualStudio.TraceCollector.CommonDataCollector.OnInitialize(XmlElement configurationElement) 2016-07-01T06:40:25.3532321Z ##[error] at Microsoft.VisualStudio.TraceCollector.BaseDataCollector.InternalConstruct(XmlElement configurationElement,IDataCollectionEvents events,IDataCollectionSink dataSink,IDataCollectionLogger logger,IDataCollectionAgentContext agentContext) 2016-07-01T06:40:25.3532321Z ##[error] at Microsoft.VisualStudio.TraceCollector.BaseDataCollector.Initialize(XmlElement configurationElement,DataCollectionEvents events,DataCollectionSink dataSink,DataCollectionLogger logger,DataCollectionEnvironmentContext environmentContext) 2016-07-01T06:40:25.3532321Z ##[error] at WEX.TestExecution.DataCollectorTestMode.Initialize(ITestModeSettings settings,ICallbackRegistrar callbackRegistrar) 2016-07-01T06:40:25.3532321Z ##[error] 我不确定它是否必须对我们的代码覆盖做一些事情(因为堆栈跟踪提到了这个数据采集器).我们使用runsettings文件从代码覆盖中输入/排除某些内容. 在构建服务器上,我们安装了Visual Studio 2015 Update 3(但问题出现在Update 2中),TFS是2015版RTM. 显然锁定的文件并不总是相同,但它始终是“FakeTypeCaches”之一. 任何帮助,将不胜感激 谢谢 编辑 似乎问题是由并行运行单元测试引起的(我认为该选项自VS 2015 Update 1起可用).并行运行它们似乎已经解决了问题,但遗憾的是,运行我们的测试现在需要相当长的时间来运行.特别是对于我们的CI构建,这并不理想,因为我们希望尽快得到反馈. 我们现在解决这个问题的方法是用TestCategory标记所有使用Fakes / Shims的测试:[TestCategory(“Sequential”)] 在构建服务器上,我们定义了两个单元测试步骤,除了“Sequential”之外的所有类别的第一个过滤器并行运行,第二个然后不并行运行“Sequential”. 解决方法
根据错误消息,似乎其他进程持有该文件.
尝试使用 this tool来确定哪个文件正好被哪个进程锁定.然后在建筑物正在进行时停止该过程. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |