Пример #1
0
        public async Task <bool> DeleteFilesAsync(IEnumerable <string> relativeFilePaths, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            List <string> absolutePaths = new List <string>();

            foreach (string filePath in relativeFilePaths)
            {
                string   absoluteFilePath = Path.Combine(WorkingDirectory, filePath);
                FileInfo file             = new FileInfo(absoluteFilePath);

                if (file.Exists)
                {
                    absolutePaths.Add(absoluteFilePath);
                }
            }

            //Delete from project
            Project project       = VsHelpers.GetDTEProjectFromConfig(_configFilePath);
            bool    isCoreProject = await VsHelpers.IsDotNetCoreWebProjectAsync(project);

            if (!isCoreProject)
            {
                var  logAction         = new Action <string, LogLevel>((message, level) => { Logger.Log(message, level); });
                bool deleteFromProject = await VsHelpers.DeleteFilesFromProjectAsync(project, absolutePaths, logAction, cancellationToken);

                if (deleteFromProject)
                {
                    return(true);
                }
            }

            // Delete from file system
            return(await DeleteFilesFromDisk(absolutePaths, cancellationToken));
        }