예제 #1
0
        private async Task AddFilesToProjectAsync(string configFilePath, Project project, IEnumerable <ILibraryOperationResult> results, CancellationToken cancellationToken)
        {
            string workingDirectory = Path.GetDirectoryName(configFilePath);
            var    files            = new List <string>();

            if (project != null)
            {
                foreach (ILibraryOperationResult state in results)
                {
                    if (state.Success && !state.UpToDate && state.InstallationState.Files != null)
                    {
                        IEnumerable <string> absoluteFiles = state.InstallationState.Files
                                                             .Select(file => Path.Combine(workingDirectory, state.InstallationState.DestinationPath, file)
                                                                     .Replace('/', Path.DirectorySeparatorChar));
                        files.AddRange(absoluteFiles);
                    }
                }

                if (files.Count > 0)
                {
                    var logAction = new Action <string, LogLevel>((message, level) => { Logger.LogEvent(message, level); });
                    await VsHelpers.AddFilesToProjectAsync(project, files, logAction, cancellationToken);
                }
            }
        }