Beispiel #1
0
        private async Task <IProject> WaitForValidProjectJsonAsync(string projectFile, CancellationToken cancellationToken)
        {
            IProject project = null;

            while (true)
            {
                string errors;
                if (_projectProvider.TryReadProject(projectFile, out project, out errors))
                {
                    return(project);
                }

                _logger.LogError($"Error(s) reading project file '{projectFile}': ");
                _logger.LogError(errors);
                _logger.LogInformation("Fix the error to continue.");

                using (var fileWatcher = _fileWatcherFactory(Path.GetDirectoryName(projectFile)))
                {
                    fileWatcher.WatchFile(projectFile);
                    fileWatcher.WatchProject(projectFile);

                    await WatchForFileChangeAsync(fileWatcher, cancellationToken);

                    if (cancellationToken.IsCancellationRequested)
                    {
                        return(null);
                    }

                    _logger.LogInformation($"File changed: {projectFile}");
                }
            }
        }
Beispiel #2
0
        private async Task WaitForValidProjectJsonAsync(string projectFile, CancellationToken cancellationToken)
        {
            while (true)
            {
                IProject project;
                string   errors;
                if (_projectProvider.TryReadProject(projectFile, out project, out errors))
                {
                    return;
                }

                _logger.LogError($"Error(s) reading project file '{projectFile}': ");
                _logger.LogError(errors);
                _logger.LogInformation("Fix the error to continue.");

                using (var projectWatcher = CreateProjectWatcher(projectFile, watchProjectJsonOnly: true))
                {
                    await projectWatcher.WaitForChangeAsync(cancellationToken);

                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }

                    _logger.LogInformation($"File changed: {projectFile}");
                }
            }
        }
Beispiel #3
0
        private void GetProjectFilesClosure(string projectFile, ISet <string> closure)
        {
            closure.Add(projectFile);

            IProject project;
            string   errors;

            if (_projectProvider.TryReadProject(projectFile, out project, out errors))
            {
                foreach (var file in project.Files)
                {
                    closure.Add(file);
                }

                foreach (var dependency in project.ProjectDependencies)
                {
                    GetProjectFilesClosure(dependency, closure);
                }
            }
        }