diff --git a/src/OmniSharp.MSBuild/ProjectManager.cs b/src/OmniSharp.MSBuild/ProjectManager.cs index c545906e24..a58c491fb5 100644 --- a/src/OmniSharp.MSBuild/ProjectManager.cs +++ b/src/OmniSharp.MSBuild/ProjectManager.cs @@ -366,6 +366,8 @@ private void AddProject(ProjectFileInfo projectFileInfo) var newSolution = _workspace.CurrentSolution.AddProject(projectInfo); _workspace.AddDocumentInclusionRuleForProject(projectInfo.Id, (filePath) => projectFileInfo.IsFileIncluded(filePath)); + SubscribeToAnalyzerReferenceLoadFailures(projectInfo.AnalyzerReferences.Cast(), _logger); + if (!_workspace.TryApplyChanges(newSolution)) { _logger.LogError($"Failed to add project to workspace: '{projectFileInfo.FilePath}'"); @@ -478,10 +480,22 @@ private void UpdateAnalyzerReferences(Project project, ProjectFileInfo projectFi { var analyzerFileReferences = projectFileInfo.ResolveAnalyzerReferencesForProject(_analyzerAssemblyLoader); + SubscribeToAnalyzerReferenceLoadFailures(analyzerFileReferences, _logger); _workspace.SetAnalyzerReferences(project.Id, analyzerFileReferences); } + private void SubscribeToAnalyzerReferenceLoadFailures(IEnumerable analyzerFileReferences, ILogger logger) + { + foreach (var analyzerFileReference in analyzerFileReferences) + { + analyzerFileReference.AnalyzerLoadFailed += (sender, e) => + { + logger.LogError($"Failure while loading the analyzer reference '{analyzerFileReference.Display}': {e.Message}"); + }; + } + } + private void UpdateProjectProperties(Project project, ProjectFileInfo projectFileInfo) { if (projectFileInfo.DefaultNamespace != project.DefaultNamespace)