예제 #1
0
        private async Task <int> ExecuteAsync(CancellationToken cancellationToken)
        {
            // Create a Workspace
            var workspace = MSBuildWorkspace.Create();

            // Load the solution/projects
            if (!await LoadProjectsAsync(workspace, cancellationToken))
            {
                return(1);
            }

            _logger.LogDebug("Prepared workspace.");

            // Create an indexer
            var indexer = new Indexer(_loggerFactory);

            // Build a snapshot index
            var snapshot = await indexer.BuildIndexAsync(_snapshotName, workspace, cancellationToken);

            // Save the snapshot index according to the storage options.
            if (_storage == null)
            {
                _logger.LogWarning("Skipping storage as no storage options were specified.");
            }
            else
            {
                _logger.LogInformation("Saving index data...");
                await _storage.StoreSnapshotAsync(snapshot, cancellationToken);

                _logger.LogInformation("Saved index data.");
            }

            return(0);
        }