From 55c812e30431ef09fc01b70e4e2d4d588a285c10 Mon Sep 17 00:00:00 2001 From: XU Zhaofeng Date: Thu, 2 Dec 2021 23:00:52 +1300 Subject: [PATCH] Pass the logger for loading projects. So errors occur in loading projects can be printed out. omnisharp-vscode issue #4832 --- src/OmniSharp.MSBuild/ProjectLoader.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/OmniSharp.MSBuild/ProjectLoader.cs b/src/OmniSharp.MSBuild/ProjectLoader.cs index 92cc4af90a..b4250a435a 100644 --- a/src/OmniSharp.MSBuild/ProjectLoader.cs +++ b/src/OmniSharp.MSBuild/ProjectLoader.cs @@ -72,18 +72,18 @@ private static Dictionary CreateGlobalProperties( { using (_sdksPathResolver.SetSdksPathEnvironmentVariable(filePath)) { - var evaluatedProject = EvaluateProjectFileCore(filePath, configurationsInSolution); - - SetTargetFrameworkIfNeeded(evaluatedProject); - - var projectInstance = evaluatedProject.CreateProjectInstance(); var msbuildLogger = new MSBuildLogger(_logger); - var loggers = new List() { msbuildLogger }; + var evaluatedProject = EvaluateProjectFileCore(filePath, configurationsInSolution, loggers); + + SetTargetFrameworkIfNeeded(evaluatedProject); + + var projectInstance = evaluatedProject.CreateProjectInstance(); + if (_options.GenerateBinaryLogs) { var binlogPath = Path.ChangeExtension(projectInstance.FullPath, ".binlog"); @@ -116,7 +116,7 @@ public MSB.Evaluation.Project EvaluateProjectFile(string filePath) } } - private MSB.Evaluation.Project EvaluateProjectFileCore(string filePath, IReadOnlyDictionary projectConfigurationsInSolution = null) + private MSB.Evaluation.Project EvaluateProjectFileCore(string filePath, IReadOnlyDictionary projectConfigurationsInSolution = null, IList loggers = null) { var localProperties = new Dictionary(_globalProperties); if (projectConfigurationsInSolution != null @@ -146,7 +146,7 @@ private MSB.Evaluation.Project EvaluateProjectFileCore(string filePath, IReadOnl } // Evaluate the MSBuild project - var projectCollection = new MSB.Evaluation.ProjectCollection(localProperties); + var projectCollection = new MSB.Evaluation.ProjectCollection(localProperties, loggers, Microsoft.Build.Evaluation.ToolsetDefinitionLocations.Default); var toolsVersion = _options.ToolsVersion; if (string.IsNullOrEmpty(toolsVersion) || Version.TryParse(toolsVersion, out _))