Skip to content

Commit

Permalink
Change Copy task LogDiagnostics Warning so it is suppressible (#9217)
Browse files Browse the repository at this point in the history
Fixes #9210 by adding codes to the retrying-copy messages.
  • Loading branch information
rokonec committed Sep 21, 2023
1 parent 6ed9b1f commit 3847162
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Tasks/Copy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ internal static void RefreshInternalEnvironmentValues()
/// If MSBUILDALWAYSRETRY is set, also log useful diagnostic information -- as
/// a warning, so it's easily visible.
/// </summary>
private void LogDiagnostic(string message, params object[] messageArgs)
private void LogAlwaysRetryDiagnosticFromResources(string messageResourceName, params object[] messageArgs)
{
if (s_alwaysRetryCopy)
{
Log.LogWarning(message, messageArgs);
Log.LogWarningWithCodeFromResources(messageResourceName, messageArgs);
}
}

Expand Down Expand Up @@ -823,7 +823,7 @@ private bool DoCopyWithRetries(FileState sourceFileState, FileState destinationF
case IOException: // Not clear why we can get one and not the other
int code = Marshal.GetHRForException(e);

LogDiagnostic("Got {0} copying {1} to {2} and HR is {3}", e.ToString(), sourceFileState.Name, destinationFileState.Name, code);
LogAlwaysRetryDiagnosticFromResources("Copy.IOException", e.ToString(), sourceFileState.Name, destinationFileState.Name, code);
if (code == NativeMethods.ERROR_ACCESS_DENIED)
{
// ERROR_ACCESS_DENIED can either mean there's an ACL preventing us, or the file has the readonly bit set.
Expand All @@ -839,7 +839,7 @@ private bool DoCopyWithRetries(FileState sourceFileState, FileState destinationF
}
else
{
LogDiagnostic("Retrying on ERROR_ACCESS_DENIED because MSBUILDALWAYSRETRY = 1");
LogAlwaysRetryDiagnosticFromResources("Copy.RetryingOnAccessDenied");
}
}
else if (code == NativeMethods.ERROR_INVALID_FILENAME)
Expand Down
8 changes: 8 additions & 0 deletions src/Tasks/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2781,6 +2781,14 @@
<value>MSB3893: Could not use a link to copy "{0}" to "{1}".</value>
<comment>{StrBegin="MSB3893: "} LOCALIZATION: {0} and {1} are paths.</comment>
</data>
<data name="Copy.IOException">
<value>MSB3894: "Got {0} copying {1} to {2} and HR is {3}"</value>
<comment>{StrBegin="MSB3894: "} LOCALIZATION: {0} is exception.ToString(), {1} and {2} are paths, {3} is a number")</comment>
</data>
<data name="Copy.RetryingOnAccessDenied">
<value>"MSB3895: Retrying on ERROR_ACCESS_DENIED because environment variable MSBUILDALWAYSRETRY = 1"</value>
<comment>{StrBegin="MSB3895: "} LOCALIZATION: Do NOT translate MSBUILDALWAYSRETRY")</comment>
</data>

<!--
MSB3901 - MSB3910 Task: Telemetry
Expand Down
10 changes: 10 additions & 0 deletions src/Tasks/Resources/xlf/Strings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Tasks/Resources/xlf/Strings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Tasks/Resources/xlf/Strings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Tasks/Resources/xlf/Strings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Tasks/Resources/xlf/Strings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Tasks/Resources/xlf/Strings.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Tasks/Resources/xlf/Strings.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Tasks/Resources/xlf/Strings.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Tasks/Resources/xlf/Strings.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3847162

Please sign in to comment.