Skip to content

Commit 3847162

Browse files
authored
Change Copy task LogDiagnostics Warning so it is suppressible (#9217)
Fixes #9210 by adding codes to the retrying-copy messages.
1 parent 6ed9b1f commit 3847162

15 files changed

+142
-4
lines changed

src/Tasks/Copy.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,11 @@ internal static void RefreshInternalEnvironmentValues()
211211
/// If MSBUILDALWAYSRETRY is set, also log useful diagnostic information -- as
212212
/// a warning, so it's easily visible.
213213
/// </summary>
214-
private void LogDiagnostic(string message, params object[] messageArgs)
214+
private void LogAlwaysRetryDiagnosticFromResources(string messageResourceName, params object[] messageArgs)
215215
{
216216
if (s_alwaysRetryCopy)
217217
{
218-
Log.LogWarning(message, messageArgs);
218+
Log.LogWarningWithCodeFromResources(messageResourceName, messageArgs);
219219
}
220220
}
221221

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

826-
LogDiagnostic("Got {0} copying {1} to {2} and HR is {3}", e.ToString(), sourceFileState.Name, destinationFileState.Name, code);
826+
LogAlwaysRetryDiagnosticFromResources("Copy.IOException", e.ToString(), sourceFileState.Name, destinationFileState.Name, code);
827827
if (code == NativeMethods.ERROR_ACCESS_DENIED)
828828
{
829829
// ERROR_ACCESS_DENIED can either mean there's an ACL preventing us, or the file has the readonly bit set.
@@ -839,7 +839,7 @@ private bool DoCopyWithRetries(FileState sourceFileState, FileState destinationF
839839
}
840840
else
841841
{
842-
LogDiagnostic("Retrying on ERROR_ACCESS_DENIED because MSBUILDALWAYSRETRY = 1");
842+
LogAlwaysRetryDiagnosticFromResources("Copy.RetryingOnAccessDenied");
843843
}
844844
}
845845
else if (code == NativeMethods.ERROR_INVALID_FILENAME)

src/Tasks/Resources/Strings.resx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2781,6 +2781,14 @@
27812781
<value>MSB3893: Could not use a link to copy "{0}" to "{1}".</value>
27822782
<comment>{StrBegin="MSB3893: "} LOCALIZATION: {0} and {1} are paths.</comment>
27832783
</data>
2784+
<data name="Copy.IOException">
2785+
<value>MSB3894: "Got {0} copying {1} to {2} and HR is {3}"</value>
2786+
<comment>{StrBegin="MSB3894: "} LOCALIZATION: {0} is exception.ToString(), {1} and {2} are paths, {3} is a number")</comment>
2787+
</data>
2788+
<data name="Copy.RetryingOnAccessDenied">
2789+
<value>"MSB3895: Retrying on ERROR_ACCESS_DENIED because environment variable MSBUILDALWAYSRETRY = 1"</value>
2790+
<comment>{StrBegin="MSB3895: "} LOCALIZATION: Do NOT translate MSBUILDALWAYSRETRY")</comment>
2791+
</data>
27842792

27852793
<!--
27862794
MSB3901 - MSB3910 Task: Telemetry

src/Tasks/Resources/xlf/Strings.cs.xlf

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Resources/xlf/Strings.de.xlf

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Resources/xlf/Strings.es.xlf

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Resources/xlf/Strings.fr.xlf

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Resources/xlf/Strings.it.xlf

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Resources/xlf/Strings.ja.xlf

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Resources/xlf/Strings.ko.xlf

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Resources/xlf/Strings.pl.xlf

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)