Esempio n. 1
0
            public async Task <ImmutableArray <ProjectInfo> > LoadAsync(CancellationToken cancellationToken)
            {
                var results        = ImmutableArray.CreateBuilder <ProjectInfo>();
                var processedPaths = new HashSet <string>(PathUtilities.Comparer);

                _buildManager.StartBatchBuild(_globalProperties);
                try
                {
                    foreach (var projectPath in _requestedProjectPaths)
                    {
                        cancellationToken.ThrowIfCancellationRequested();

                        if (!_pathResolver.TryGetAbsoluteProjectPath(projectPath, _baseDirectory, _requestedProjectOptions.OnPathFailure, out var absoluteProjectPath))
                        {
                            continue; // Failure should already be reported.
                        }

                        if (!processedPaths.Add(absoluteProjectPath))
                        {
                            _diagnosticReporter.Report(
                                new WorkspaceDiagnostic(
                                    WorkspaceDiagnosticKind.Warning,
                                    string.Format(WorkspaceMSBuildResources.Duplicate_project_discovered_and_skipped_0, absoluteProjectPath)));

                            continue;
                        }

                        var projectFileInfos = await LoadProjectInfosFromPathAsync(absoluteProjectPath, _requestedProjectOptions, cancellationToken).ConfigureAwait(false);

                        results.AddRange(projectFileInfos);
                    }

                    foreach (var(projectPath, projectInfos) in _pathToDiscoveredProjectInfosMap)
                    {
                        cancellationToken.ThrowIfCancellationRequested();

                        if (!processedPaths.Contains(projectPath))
                        {
                            results.AddRange(projectInfos);
                        }
                    }

                    return(results.ToImmutable());
                }
                finally
                {
                    _buildManager.EndBatchBuild();
                }
            }
Esempio n. 2
0
        public bool TryGetAbsoluteSolutionPath(string path, string baseDirectory, DiagnosticReportingMode reportingMode, out string absolutePath)
        {
            try
            {
                absolutePath = GetAbsolutePath(path, baseDirectory);
            }
            catch (Exception)
            {
                _diagnosticReporter.Report(reportingMode, string.Format(WorkspacesResources.Invalid_solution_file_path_colon_0, path));
                absolutePath = null;
                return(false);
            }

            if (!File.Exists(absolutePath))
            {
                _diagnosticReporter.Report(
                    reportingMode,
                    string.Format(WorkspacesResources.Solution_file_not_found_colon_0, absolutePath),
                    msg => new FileNotFoundException(msg));
                return(false);
            }

            return(true);
        }