c# – TFS Build失败,“无法访问文件* FakeTypesCache”
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c# – TFS Build失败,“无法访问文件* FakeTypesCache”,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3920字,纯文字阅读大概需要6分钟。
内容图文
几天以来,我们遇到了TFS构建问题.我们使用Microsoft Shims / Fakes进行一些单元测试,到目前为止我们没有遇到任何问题.
但最近UnitTest Step因以下错误而失败:
每隔一段时间就会发生以下情况:
2016-07-01T06:40:25.3532321Z ##[error]Error: System.IO.IOException: The process cannot access the file 'D:\Builds\Agent\87a4a39e\...\bin\Debug\mscorlib.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, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
2016-07-01T06:40:25.3532321Z ##[error] at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, 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构建,这并不理想,因为我们希望尽快得到反馈.
如果我们只能按顺序运行使用Faked / Stubbed类的测试,那么我知道我不知道如何实现这一点.
我们现在解决这个问题的方法是用TestCategory标记所有使用Fakes / Shims的测试:[TestCategory(“Sequential”)]
在构建服务器上,我们定义了两个单元测试步骤,除了“Sequential”之外的所有类别的第一个过滤器并行运行,第二个然后不并行运行“Sequential”.
解决方法:
根据错误消息,似乎其他进程持有该文件.
尝试使用this tool来确定哪个文件正好被哪个进程锁定.然后在建筑物正在进行时停止该过程.
内容总结
以上是互联网集市为您收集整理的c# – TFS Build失败,“无法访问文件* FakeTypesCache”全部内容,希望文章能够帮你解决c# – TFS Build失败,“无法访问文件* FakeTypesCache”所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。