C# TFS生成失败,返回“0”;无法访问文件*FakeTypesCache";

C# TFS生成失败,返回“0”;无法访问文件*FakeTypesCache";,c#,visual-studio,tfs,C#,Visual Studio,Tfs,几天以来,我们的TFS构建遇到了问题。我们在一些单元测试中使用了微软垫片/赝品,到目前为止,我们没有遇到任何问题。 但最近,在上的UnitTest步骤失败,出现以下错误: 以下情况每隔一段时间就会发生一次: 2016-07-01T06:40:25.3532321Z ##[error]Error: System.IO.IOException: The process cannot access the file 'D:\Builds\Agent\87a4a39e\...\bin\Debug\msc

几天以来,我们的TFS构建遇到了问题。我们在一些单元测试中使用了微软垫片/赝品,到目前为止,我们没有遇到任何问题。 但最近,在上的UnitTest步骤失败,出现以下错误: 以下情况每隔一段时间就会发生一次:

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更新3(但更新2也出现了问题),TFS版本为2015 RTM

显然被锁定的文件并不总是相同的,但它始终是“FakeTypeCache”之一

任何帮助都将不胜感激

谢谢

编辑

这个问题似乎是由并行运行单元测试引起的(我认为这个选项从VS2015更新1开始就可用)。不并行运行它们似乎解决了这个问题,但遗憾的是,现在运行我们的测试需要相当长的时间。尤其是对于我们的CI构建,这并不理想,因为我们希望尽快获得反馈。 如果我们只能按顺序运行使用伪造/存根类的测试,那将是理想的,但我不知道如何实现这一点

我们现在解决这个问题的解决方案是用TestCategory:[TestCategory(“Sequential”)]标记所有以任何方式使用假货/垫片的测试


在构建服务器上,我们定义了两个单元测试步骤,第一个过滤除“Sequential”之外的所有类别,并并行运行,第二个则不并行运行“Sequential”。

根据错误消息,似乎其他进程持有该文件。
尝试使用来确定哪个文件正被哪个进程锁定。然后在构建过程中停止该过程。

这是中修复的已知问题


您只需获取Visual Studio的最新更新,在回答此问题时,它是:

我们正在按承诺进行TFS2015更新3,我们在并行运行单元测试时也遇到了同样的问题。 我们的短期解决方案是禁用存储库清理选项,并且只使用MSBuild clean,所以这些伪造缓存文件不会被清理。似乎只有在多个测试同时尝试创建伪造缓存文件时才会发生错误

但是,禁用存储库清理选项后,我们还遇到了一些其他随机的恼人问题:(

如果你有更好的方法来避免这个问题,请告诉我。 谢谢
Angel

您的生成服务器上是否有多个生成代理?如果您尝试使用另一个生成代理生成此版本,结果会如何?您好,生成服务器上只有一个生成代理。您好,当问题首次出现时,我们实际使用的是Visual Studio Update 2。现在我们已升级到Update 3,我将再试一次。我们有是问题,并且我们的生成服务器有Visual Studio 2015更新3。在提供的链接中,相关的已知问题是什么?我看不到任何相关的内容。更新3也存在问题。