Exemplo n.º 1
0
        private void UpdateProject(string projectDirectory)
        {
            _logger.LogInformation($"Update project {projectDirectory}");
            var contexts = _workspaceContext.GetProjectContexts(projectDirectory);

            if (!contexts.Any())
            {
                _logger.LogWarning($"Cannot create any {nameof(ProjectContext)} from project {projectDirectory}");
                return;
            }

            var projectFilePath = contexts.First().ProjectFile.ProjectFilePath;

            _emitter.Emit(
                EventTypes.ProjectChanged,
                new ProjectInformationResponse()
            {
                // the key is hard coded in VSCode
                {
                    "DnxProject",
                    new
                    {
                        Path        = projectFilePath,
                        SourceFiles = Enumerable.Empty <string>()
                    }
                }
            });

            _projectStates.Update(projectDirectory, contexts, AddProject, _omnisharpWorkspace.RemoveProject);

            _watcher.Watch(projectFilePath, file =>
            {
                _logger.LogInformation($"Watcher: {file} updated.");
                Update(true);
            });

            _watcher.Watch(Path.ChangeExtension(projectFilePath, "lock.json"), file =>
            {
                _logger.LogInformation($"Watcher: {file} updated.");
                Update(false);
            });
        }