diff --git a/src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs b/src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs index 48ca3bbf..f3931042 100644 --- a/src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs +++ b/src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs @@ -28,7 +28,7 @@ public IReadOnlyDictionary SetCloudBuildNumber(string buildNumbe public IReadOnlyDictionary SetCloudBuildVariable(string name, string value, TextWriter stdout, TextWriter stderr) { - Utilities.FileOperationWithRetry(() => File.AppendAllText(EnvironmentFile, $"{Environment.NewLine}{name}={value}{Environment.NewLine}")); + Utilities.FileOperationWithRetry(() => File.AppendAllLines(EnvironmentFile, new [] {$"{name}={value}"})); return GetDictionaryFor(name, value); } diff --git a/src/Shared/Utilities.cs b/src/Shared/Utilities.cs index 9e375f66..c20f34a0 100644 --- a/src/Shared/Utilities.cs +++ b/src/Shared/Utilities.cs @@ -19,6 +19,7 @@ internal static void FileOperationWithRetry(Action operation) try { operation(); + break; } catch (IOException ex) when (ex.HResult == ProcessCannotAccessFileHR && retriesLeft > 0) {