Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions src/Workspaces/MSBuild/BuildHost/Build/ProjectBuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ private static (MSB.Evaluation.Project? project, DiagnosticLog log) LoadProjectC
{
var projectCollection = new MSB.Evaluation.ProjectCollection(
AllGlobalProperties,
_msbuildLogger != null ? [_msbuildLogger] : ImmutableArray<MSB.Framework.ILogger>.Empty,
// https://github.com/dotnet/msbuild/issues/11867: workaround LoggerException when passing binary logger to both evaluation and build
loggers: [],
MSB.Evaluation.ToolsetDefinitionLocations.Default);
try
{
Expand All @@ -171,18 +172,26 @@ private static (MSB.Evaluation.Project? project, DiagnosticLog log) LoadProjectC
var log = new DiagnosticLog();
try
{
var projectCollection = new MSB.Evaluation.ProjectCollection(
AllGlobalProperties,
_msbuildLogger != null ? [_msbuildLogger] : ImmutableArray<MSB.Framework.ILogger>.Empty,
MSB.Evaluation.ToolsetDefinitionLocations.Default);
try
if (BatchBuildStarted)
{
return LoadProjectCore(path, readStream, projectCollection, log);
return LoadProjectCore(path, readStream, _batchBuildProjectCollection, log);
}
finally
else
{
// unload project so collection will release global strings
projectCollection.UnloadAllProjects();
var projectCollection = new MSB.Evaluation.ProjectCollection(
AllGlobalProperties,
// https://github.com/dotnet/msbuild/issues/11867: workaround LoggerException when passing binary logger to both evaluation and build
loggers: [],
MSB.Evaluation.ToolsetDefinitionLocations.Default);
try
{
return LoadProjectCore(path, readStream, projectCollection, log);
}
finally
{
// unload project so collection will release global strings
projectCollection.UnloadAllProjects();
}
}
}
catch (Exception e)
Expand Down Expand Up @@ -228,7 +237,8 @@ public void StartBatchBuild(IDictionary<string, string>? globalProperties = null
? [_msbuildLogger]
: ImmutableArray<MSB.Framework.ILogger>.Empty;

_batchBuildProjectCollection = new MSB.Evaluation.ProjectCollection(allProperties, loggers, MSB.Evaluation.ToolsetDefinitionLocations.Default);
// Pass empty loggers array to workaround LoggerException when passing binary logger to both evaluation and build. See https://github.com/dotnet/msbuild/issues/11867
_batchBuildProjectCollection = new MSB.Evaluation.ProjectCollection(allProperties, loggers: [], MSB.Evaluation.ToolsetDefinitionLocations.Default);

var buildParameters = new MSB.Execution.BuildParameters(_batchBuildProjectCollection)
{
Expand Down
Loading