public void Initalize(IConfiguration configuration)
        {
            _options = new MSBuildOptions();
            ConfigurationBinder.Bind(configuration, _options);

            if (_environment.LogLevel < LogLevel.Information)
            {
                var buildEnvironmentInfo = MSBuildHelpers.GetBuildEnvironmentInfo();
                _logger.LogDebug($"MSBuild environment: {Environment.NewLine}{buildEnvironmentInfo}");
            }

            _packageDependencyChecker = new PackageDependencyChecker(_loggerFactory, _eventEmitter, _dotNetCli, _options);
            _loader  = new ProjectLoader(_options, _environment.TargetDirectory, _propertyOverrides, _loggerFactory, _sdksPathResolver);
            _manager = new ProjectManager(_loggerFactory, _eventEmitter, _fileSystemWatcher, _metadataFileReferenceCache, _packageDependencyChecker, _loader, _workspace);

            var initialProjectPaths = GetInitialProjectPaths();

            foreach (var projectFilePath in initialProjectPaths)
            {
                if (!File.Exists(projectFilePath))
                {
                    _logger.LogWarning($"Found project that doesn't exist on disk: {projectFilePath}");
                    continue;
                }

                _manager.QueueProjectUpdate(projectFilePath, allowAutoRestore: true);
            }
        }
Ejemplo n.º 2
0
        public ProjectManager(ILoggerFactory loggerFactory,
                              MSBuildOptions options,
                              IEventEmitter eventEmitter,
                              IFileSystemWatcher fileSystemWatcher,
                              MetadataFileReferenceCache metadataFileReferenceCache,
                              PackageDependencyChecker packageDependencyChecker,
                              ProjectLoader projectLoader,
                              OmniSharpWorkspace workspace,
                              ImmutableArray <IMSBuildEventSink> eventSinks)
        {
            _logger                     = loggerFactory.CreateLogger <ProjectManager>();
            _options                    = options ?? new MSBuildOptions();
            _eventEmitter               = eventEmitter;
            _fileSystemWatcher          = fileSystemWatcher;
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _packageDependencyChecker   = packageDependencyChecker;
            _projectFiles               = new ProjectFileInfoCollection();
            _failedToLoadProjectFiles   = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
            _projectsRequestedOnDemand  = new ConcurrentDictionary <string, int>(StringComparer.OrdinalIgnoreCase);
            _projectLoader              = projectLoader;
            _workspace                  = workspace;
            _eventSinks                 = eventSinks;

            _queue = new BufferBlock <ProjectToUpdate>();
            _processLoopCancellation = new CancellationTokenSource();
            _processLoopTask         = Task.Run(() => ProcessLoopAsync(_processLoopCancellation.Token));

            _onDirectoryFileChanged = OnDirectoryFileChanged;

            if (_options.LoadProjectsOnDemand)
            {
                _workspace.AddWaitForProjectModelReadyHandler(WaitForProjectModelReadyAsync);
            }
        }
Ejemplo n.º 3
0
        public ProjectManager(ILoggerFactory loggerFactory, IEventEmitter eventEmitter, IFileSystemWatcher fileSystemWatcher, MetadataFileReferenceCache metadataFileReferenceCache, PackageDependencyChecker packageDependencyChecker, ProjectLoader projectLoader, OmniSharpWorkspace workspace)
        {
            _logger                     = loggerFactory.CreateLogger <ProjectManager>();
            _eventEmitter               = eventEmitter;
            _fileSystemWatcher          = fileSystemWatcher;
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _packageDependencyChecker   = packageDependencyChecker;
            _projectFiles               = new ProjectFileInfoCollection();
            _projectLoader              = projectLoader;
            _workspace                  = workspace;

            _queue = new BufferBlock <ProjectToUpdate>();
            _processLoopCancellation = new CancellationTokenSource();
            _processLoopTask         = Task.Run(() => ProcessLoopAsync(_processLoopCancellation.Token));
        }
Ejemplo n.º 4
0
        public void Initalize(IConfiguration configuration)
        {
            if (Initialized)
            {
                return;
            }

            _options = new MSBuildOptions();
            ConfigurationBinder.Bind(configuration, _options);

            _sdksPathResolver.Enabled      = _options.UseLegacySdkResolver;
            _sdksPathResolver.OverridePath = _options.MSBuildSDKsPath;

            if (_environment.LogLevel < LogLevel.Information)
            {
                var buildEnvironmentInfo = MSBuildHelpers.GetBuildEnvironmentInfo();
                _logger.LogDebug($"MSBuild environment: {Environment.NewLine}{buildEnvironmentInfo}");
            }

            _packageDependencyChecker = new PackageDependencyChecker(_loggerFactory, _eventEmitter, _dotNetCli, _options);
            _loader = new ProjectLoader(_options, _environment.TargetDirectory, _propertyOverrides, _loggerFactory, _sdksPathResolver);

            var dotNetInfo = GetDotNetInfo();

            _manager    = new ProjectManager(_loggerFactory, _options, _eventEmitter, _fileSystemWatcher, _metadataFileReferenceCache, _packageDependencyChecker, _loader, _workspace, _assemblyLoader, _eventSinks, dotNetInfo);
            Initialized = true;

            if (_options.LoadProjectsOnDemand)
            {
                _logger.LogInformation($"Skip loading projects listed in solution file or under target directory because {Key}:{nameof(MSBuildOptions.LoadProjectsOnDemand)} is true.");
                return;
            }

            var initialProjectPathsAndIds = GetInitialProjectPathsAndIds();

            foreach (var(projectFilePath, projectIdInfo) in initialProjectPathsAndIds)
            {
                if (!File.Exists(projectFilePath))
                {
                    _logger.LogWarning($"Found project that doesn't exist on disk: {projectFilePath}");
                    continue;
                }

                _manager.QueueProjectUpdate(projectFilePath, allowAutoRestore: true, projectIdInfo);
            }
        }
Ejemplo n.º 5
0
        public ProjectManager(ILoggerFactory loggerFactory, IEventEmitter eventEmitter, IFileSystemWatcher fileSystemWatcher, MetadataFileReferenceCache metadataFileReferenceCache, PackageDependencyChecker packageDependencyChecker, ProjectLoader projectLoader, OmniSharpWorkspace workspace, ImmutableArray <IMSBuildEventSink> eventSinks)
        {
            _logger                     = loggerFactory.CreateLogger <ProjectManager>();
            _eventEmitter               = eventEmitter;
            _fileSystemWatcher          = fileSystemWatcher;
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _packageDependencyChecker   = packageDependencyChecker;
            _projectFiles               = new ProjectFileInfoCollection();
            _failedToLoadProjectFiles   = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
            _projectLoader              = projectLoader;
            _workspace                  = workspace;
            _eventSinks                 = eventSinks;

            _queue = new BufferBlock <ProjectToUpdate>();
            _processLoopCancellation = new CancellationTokenSource();
            _processLoopTask         = Task.Run(() => ProcessLoopAsync(_processLoopCancellation.Token));

            _onDirectoryFileChanged = OnDirectoryFileChanged;
        }