Microsoft.Build.dll!Microsoft.Build.Logging.BinaryLogger.Initialize(Microsoft.Build.Framework.IEventSource eventSource) Line 79 C#
Microsoft.Build.dll!Microsoft.Build.Evaluation.ProjectCollection.ReusableLogger.Initialize(Microsoft.Build.Framework.IEventSource eventSource, int nodeCount) Line 221 C#
Microsoft.Build.dll!Microsoft.Build.BackEnd.Logging.LoggingService.InitializeLogger(Microsoft.Build.Framework.ILogger logger, Microsoft.Build.Framework.IEventSource sourceForLogger) Line 982 C#
Microsoft.Build.dll!Microsoft.Build.BackEnd.Logging.LoggingService.RegisterDistributedLogger(Microsoft.Build.Framework.ILogger centralLogger, Microsoft.Build.Logging.LoggerDescription forwardingLogger) Line 578 C#
Microsoft.Build.dll!Microsoft.Build.BackEnd.Logging.LoggingService.RegisterLogger(Microsoft.Build.Framework.ILogger logger) Line 537 C#
Microsoft.Build.dll!Microsoft.Build.Evaluation.ProjectCollection.RegisterLoggerInternal(Microsoft.Build.Framework.ILogger logger) Line 1660 C#
Microsoft.Build.dll!Microsoft.Build.Evaluation.ProjectCollection.RegisterLoggers(System.Collections.Generic.IEnumerable<Microsoft.Build.Framework.ILogger> loggers) Line 1405 C#
Microsoft.Build.dll!Microsoft.Build.Evaluation.ProjectCollection.ProjectCollection(System.Collections.Generic.IDictionary<string, string> globalProperties, System.Collections.Generic.IEnumerable<Microsoft.Build.Framework.ILogger> loggers, System.Collections.Generic.IEnumerable<Microsoft.Build.Logging.ForwardingLoggerRecord> remoteLoggers, Microsoft.Build.Evaluation.ToolsetDefinitionLocations toolsetDefinitionLocations, int maxNodeCount, bool onlyLogCriticalEvents, bool loadProjectsReadOnly, bool useAsynchronousLogging, bool reuseProjectRootElementCache) Line 1127 C#
Microsoft.Build.dll!Microsoft.Build.Evaluation.ProjectCollection.ProjectCollection(System.Collections.Generic.IDictionary<string, string> globalProperties, System.Collections.Generic.IEnumerable<Microsoft.Build.Framework.ILogger> loggers, System.Collections.Generic.IEnumerable<Microsoft.Build.Logging.ForwardingLoggerRecord> remoteLoggers, Microsoft.Build.Evaluation.ToolsetDefinitionLocations toolsetDefinitionLocations, int maxNodeCount, bool onlyLogCriticalEvents, bool loadProjectsReadOnly) Line 1097 C#
Microsoft.Build.dll!Microsoft.Build.Evaluation.ProjectCollection.ProjectCollection(System.Collections.Generic.IDictionary<string, string> globalProperties, System.Collections.Generic.IEnumerable<Microsoft.Build.Framework.ILogger> loggers, System.Collections.Generic.IEnumerable<Microsoft.Build.Logging.ForwardingLoggerRecord> remoteLoggers, Microsoft.Build.Evaluation.ToolsetDefinitionLocations toolsetDefinitionLocations, int maxNodeCount, bool onlyLogCriticalEvents) Line 1092 C#
Microsoft.Build.dll!Microsoft.Build.Evaluation.ProjectCollection.ProjectCollection(System.Collections.Generic.IDictionary<string, string> globalProperties, System.Collections.Generic.IEnumerable<Microsoft.Build.Framework.ILogger> loggers, Microsoft.Build.Evaluation.ToolsetDefinitionLocations toolsetDefinitionLocations) Line 1080 C#
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.dll!Microsoft.CodeAnalysis.MSBuild.ProjectBuildManager.StartBatchBuild(System.Collections.Generic.IDictionary<string, string> globalProperties) Line 231 C#
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.dll!Microsoft.CodeAnalysis.MSBuild.BuildHost.CreateBuildManager() Line 122 C#
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.dll!Microsoft.CodeAnalysis.MSBuild.BuildHost.LoadProjectCore(string projectFilePath, string projectContent, string languageName) Line 205 C#
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.dll!Microsoft.CodeAnalysis.MSBuild.BuildHost.LoadProject(string projectFilePath, string projectContent, string languageName) Line 176 C#
Context: The VS Code C# extension throws an exception when loading projects with setting
"dotnet.projects.binaryLogPath"specified.VS Code error log
What is happening is:
BinaryLogger.Initializeis being called twice. Each time a write stream to the binlog file is opened. The second time, an IOException occurs because the first time locked the file.Both calls to
BinaryLogger.Initializeoccur indirectly thru a single call toProjectBuildManager.StartBatchBuildin Roslyn.First call (thru ProjectBuildManager.cs#L231)
Second call (thru ProjectBuildManager.cs#L243)
From discussion with @dibarbet we believe this is a regression. In the past, the usage pattern shown in the linked code did not result in multiple initialization of the BinaryLogger. We were thus able to log both the evaluation and build of a project to the same binlog file at design time.