public async Task <IEnumerable <ProjectRestoreReference> > GetProjectReferencesAsync( Common.ILogger logger, CancellationToken _) { // DTE calls need to be done from the main thread await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync(); var results = new List <ProjectRestoreReference>(); var hasMissingReferences = false; var hasProjectsWithUnresolvedMetadata = false; // find all references in the project foreach (var childReference in GetVSProjectReferences()) { try { var reference3 = childReference as Reference3; // Verify that this is a project reference if (IsProjectReference(reference3, logger)) { // Verify that this is a valid and resolved project reference if (!IsReferenceResolved(reference3, logger)) { hasMissingReferences = true; continue; } if (await EnvDTEProjectUtility.HasUnsupportedProjectCapabilityAsync(reference3.SourceProject)) { // Skip this shared project continue; } var childProjectPath = reference3.SourceProject.GetFullProjectPath(); // Skip projects which have ReferenceOutputAssembly=false var addProject = true; if (childReference is Reference6 reference6) { reference6.GetMetadata(_referenceMetadata, out Array _, out Array metadataValues); var referenceOutputAssembly = GetReferenceMetadataValue(metadataValues); addProject = string.IsNullOrEmpty(referenceOutputAssembly) || !string.Equals(bool.FalseString, referenceOutputAssembly, StringComparison.OrdinalIgnoreCase); } else { hasProjectsWithUnresolvedMetadata = true; } if (addProject) { results.Add(new ProjectRestoreReference() { ProjectPath = childProjectPath, ProjectUniqueName = childProjectPath }); } } else { hasMissingReferences = true; } } catch (Exception ex) { // Exceptions are expected in some scenarios for native projects, // ignore them and show a warning hasMissingReferences = true; logger.LogDebug(ex.ToString()); Debug.Fail("Unable to find project dependencies: " + ex.ToString()); } } if (hasMissingReferences) { // Log a generic message once per project if any items could not be resolved. // In most cases this can be ignored, but in the rare case where the unresolved // item is actually a project the restore result will be incomplete. var message = string.Format( CultureInfo.CurrentCulture, Strings.UnresolvedItemDuringProjectClosureWalk, _vsProjectAdapter.UniqueName); logger.LogVerbose(message); } if (hasProjectsWithUnresolvedMetadata) { IList <string> excludedProjects = await GetExcludedProjectsAsync(logger); if (excludedProjects.Count > 0) { results = results.Where(e => !excludedProjects.Contains(e.ProjectPath, StringComparer.OrdinalIgnoreCase)).ToList(); } } return(results);