private void CopyFunctionArtifacts() { var sourceFile = string.Empty; var targetFile = string.Empty; var assemblyDir = Path.GetDirectoryName(_assemblyPath); foreach (var file in _functionsArtifacts) { sourceFile = Path.Combine(assemblyDir, file); targetFile = Path.Combine(_outputPath, file); if (File.Exists(sourceFile) && !sourceFile.Equals(targetFile, StringComparison.OrdinalIgnoreCase)) { try { File.Copy(sourceFile, targetFile, overwrite: true); } catch (Exception e) { _log.LogWarning($"Unable to copy '{sourceFile}' to '{targetFile}'"); _log.LogWarningFromException(e); } } } }
public BuildArtifactsLog(string outputPath, FakeLogger logger) { _logger = logger; _artifacts = new HashSet <string>(StringComparer.OrdinalIgnoreCase); _logPath = Path.Combine(outputPath, buildArtifactsLogName); try { if (File.Exists(_logPath)) { foreach (var line in File.ReadAllLines(_logPath)) { _artifacts.Add(line); } } } catch (Exception e) { _logger.LogWarning($"Unable to read file {_logPath}"); _logger.LogWarningFromException(e); } }
private bool Try(Action action, string message, bool isError) { try { action(); return(true); } catch (Exception e) { if (isError) { _logger.LogError(message); _logger.LogErrorFromException(e); } else { _logger.LogWarning(message); _logger.LogWarningFromException(e); } return(!isError); } }