Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass the logger for loading projects. So errors occur in loading projects can be printed out. #2288

Merged
merged 5 commits into from
Dec 7, 2021
16 changes: 8 additions & 8 deletions src/OmniSharp.MSBuild/ProjectLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ private static Dictionary<string, string> 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<MSB.Framework.ILogger>()
{
msbuildLogger
};

var evaluatedProject = EvaluateProjectFileCore(filePath, configurationsInSolution, loggers);

SetTargetFrameworkIfNeeded(evaluatedProject);

var projectInstance = evaluatedProject.CreateProjectInstance();

if (_options.GenerateBinaryLogs)
{
var binlogPath = Path.ChangeExtension(projectInstance.FullPath, ".binlog");
Expand Down Expand Up @@ -119,7 +119,7 @@ public MSB.Evaluation.Project EvaluateProjectFile(string filePath)
}
}

private MSB.Evaluation.Project EvaluateProjectFileCore(string filePath, IReadOnlyDictionary<string, string> projectConfigurationsInSolution = null)
private MSB.Evaluation.Project EvaluateProjectFileCore(string filePath, IReadOnlyDictionary<string, string> projectConfigurationsInSolution = null, IList<MSB.Framework.ILogger> loggers = null)
{
var localProperties = new Dictionary<string, string>(_globalProperties);
if (projectConfigurationsInSolution != null
Expand Down Expand Up @@ -149,7 +149,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 _))
Expand Down