Exemple #1
0
        public static ProjectSnapshot Create(string projectDirectory, string configuration, WorkspaceContext workspaceContext, IReadOnlyList <string> projectSearchPaths)
        {
            var projectContextsCollection = workspaceContext.GetProjectContextCollection(projectDirectory);

            if (!projectContextsCollection.ProjectContexts.Any())
            {
                throw new InvalidOperationException($"Unable to find project.json in '{projectDirectory}'");
            }
            GlobalSettings globalSettings;
            var            currentSearchPaths = projectContextsCollection.Project.ResolveSearchPaths(out globalSettings);

            var snapshot = new ProjectSnapshot();

            snapshot.Project            = projectContextsCollection.Project;
            snapshot.ProjectDiagnostics = new List <DiagnosticMessage>(projectContextsCollection.ProjectDiagnostics);
            snapshot.ProjectSearchPaths = currentSearchPaths.ToList();
            snapshot.GlobalJsonPath     = globalSettings?.FilePath;

            foreach (var projectContext in projectContextsCollection.ProjectContexts)
            {
                snapshot.ProjectContexts[projectContext.TargetFramework] =
                    ProjectContextSnapshot.Create(projectContext, configuration, currentSearchPaths);
            }

            return(snapshot);
        }
Exemple #2
0
        public static ProjectState Create(string appPath,
                                          string configuration,
                                          WorkspaceContext workspaceContext,
                                          IEnumerable <string> currentSearchPaths)
        {
            var projectContextsCollection = workspaceContext.GetProjectContextCollection(appPath);

            if (!projectContextsCollection.ProjectContexts.Any())
            {
                throw new InvalidOperationException($"Unable to find project.json in '{appPath}'");
            }

            var project            = projectContextsCollection.ProjectContexts.First().ProjectFile;
            var projectDiagnostics = new List <DiagnosticMessage>(projectContextsCollection.ProjectDiagnostics);
            var projectInfos       = new List <ProjectInfo>();

            foreach (var projectContext in projectContextsCollection.ProjectContexts)
            {
                projectInfos.Add(new ProjectInfo(
                                     projectContext,
                                     configuration,
                                     currentSearchPaths));
            }

            return(new ProjectState(project, projectDiagnostics, projectInfos));
        }
Exemple #3
0
        public static ProjectSnapshot Create(string projectDirectory, string configuration, WorkspaceContext workspaceContext, IReadOnlyList<string> projectSearchPaths)
        {
            var projectContextsCollection = workspaceContext.GetProjectContextCollection(projectDirectory);
            if (!projectContextsCollection.ProjectContexts.Any())
            {
                throw new InvalidOperationException($"Unable to find project.json in '{projectDirectory}'");
            }
            GlobalSettings globalSettings;
            var currentSearchPaths = projectContextsCollection.Project.ResolveSearchPaths(out globalSettings);

            var snapshot = new ProjectSnapshot();
            snapshot.Project = projectContextsCollection.Project;
            snapshot.ProjectDiagnostics = new List<DiagnosticMessage>(projectContextsCollection.ProjectDiagnostics);
            snapshot.ProjectSearchPaths = currentSearchPaths.ToList();
            snapshot.GlobalJsonPath = globalSettings?.FilePath;

            foreach (var projectContext in projectContextsCollection.ProjectContexts)
            {
                snapshot.ProjectContexts[projectContext.TargetFramework] = 
                    ProjectContextSnapshot.Create(projectContext, configuration, currentSearchPaths);
            }
            
            return snapshot;
        }