From 4b0245bdc51c282b4f30e16893aae520423d83c7 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Thu, 6 May 2021 09:27:16 -0700 Subject: [PATCH 1/2] Use msbuild logging for symbol messages Because the symbol upload internally uses the msbuild loggers, if this code uses a string builder and then prints all the info at the end, the binlog tends to look like: symbol upload diagnostic for symbol package 1 symbol upload diagnostic for symbol package 1 symbol upload diagnostic for symbol package 2 symbol upload diagnostic for symbol package 2 symbol upload diagnostic for symbol package 3 symbol upload diagnostic for symbol package 3 ... top level upload info for 1 top level upload info for 2 top level upload info for 3 Instead, it's easier to read as: top level upload info for 1 symbol upload diagnostic for symbol package 1 symbol upload diagnostic for symbol package 1 top level upload info for 2 symbol upload diagnostic for symbol package 2 symbol upload diagnostic for symbol package 2 top level upload info for 3 symbol upload diagnostic for symbol package 3 symbol upload diagnostic for symbol package 3 There will be some interleaving due to parallelism, but right now it's difficult to line up the top level messages with the diagnostic ones. --- .../src/PublishArtifactsInManifestBase.cs | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs index fed9ab0bdee..93856985ea1 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs @@ -389,8 +389,8 @@ public async Task PublishSymbolsUsingStreamingAsync( Dictionary> buildAssets, SemaphoreSlim clientThrottle) { - StringBuilder symbolLog = new StringBuilder(); - symbolLog.AppendLine("Publishing Symbols to Symbol server: "); + Log.LogMessage(MessageImportance.High, + $"Performing symbol publishing... \nExpirationInDays : {ExpirationInDays} \nConvertPortablePdbsToWindowsPdb : false \ndryRun: false "); var symbolCategory = TargetFeedContentType.Symbols; string containerId = await GetContainerIdAsync(ArtifactName.BlobArtifacts); @@ -410,6 +410,8 @@ public async Task PublishSymbolsUsingStreamingAsync( } } + Log.LogMessage(MessageImportance.High, $"Total number of symbol files : {symbolsToPublish.Count}"); + HashSet feedConfigsForSymbols = FeedConfigs[symbolCategory]; Dictionary serversToPublish = GetTargetSymbolServers(feedConfigsForSymbols, msdlToken, symWebToken); @@ -425,7 +427,7 @@ await Task.WhenAll(symbolsToPublish.Select(async symbol => await clientThrottle.WaitAsync(); string temporarySymbolsDirectory = CreateTemporaryDirectory(); string localSymbolPath = Path.Combine(temporarySymbolsDirectory, symbol); - symbolLog.AppendLine($"Downloading symbol : {symbol} to {localSymbolPath}"); + Log.LogMessage(MessageImportance.High, $"Downloading symbol : {symbol} to {localSymbolPath}"); await DownloadFileAsync( client, @@ -433,16 +435,16 @@ await DownloadFileAsync( containerId, symbol, localSymbolPath); - symbolLog.AppendLine($"Successfully downloaded symbol : {symbol} to {localSymbolPath}"); + + Log.LogMessage(MessageImportance.High, $"Successfully downloaded symbol : {symbol} to {localSymbolPath}"); List symbolFiles = new List(); symbolFiles.Add(localSymbolPath); - symbolLog.AppendLine($"Uploading symbol file '{string.Join(",", symbolFiles)}'"); foreach (var server in serversToPublish) { var serverPath = server.Key; var token = server.Value; - symbolLog.AppendLine($"Publishing symbol file {symbol} to {serverPath}:"); + Log.LogMessage(MessageImportance.High, $"Publishing symbol file {symbol} to {serverPath}:"); try { @@ -475,13 +477,7 @@ await PublishSymbolsHelper.PublishAsync( } })); - symbolLog.AppendLine( - $"Performing symbol publishing... \nExpirationInDays : {ExpirationInDays} \nConvertPortablePdbsToWindowsPdb : false \ndryRun: false "); - symbolLog.AppendLine($"Total number of symbol files : {symbolsToPublish.Count}"); - symbolLog.AppendLine("Successfully published to Symbol Server."); - symbolLog.AppendLine(); - Log.LogMessage(MessageImportance.High, symbolLog.ToString()); - symbolLog.Clear(); + Log.LogMessage(MessageImportance.High, "Successfully published to symbol servers."); } } else @@ -510,7 +506,7 @@ await PublishSymbolsHelper.PublishAsync( { var serverPath = server.Key; var token = server.Value; - symbolLog.AppendLine($"Publishing pdbFiles to {serverPath}:"); + Log.LogMessage(MessageImportance.High, $"Publishing pdbFiles to {serverPath}:"); try { @@ -606,8 +602,7 @@ public async Task PublishSymbolsfromBlobArtifactsAsync( { if (Directory.Exists(temporarySymbolsLocation)) { - StringBuilder symbolLog = new StringBuilder(); - symbolLog.AppendLine("Publishing Symbols to Symbol server: "); + Log.LogMessage(MessageImportance.High, "Publishing Symbols to Symbol server: "); string[] fileEntries = Directory.GetFiles(temporarySymbolsLocation); var category = TargetFeedContentType.Symbols; @@ -635,9 +630,8 @@ public async Task PublishSymbolsfromBlobArtifactsAsync( foreach (var server in serversToPublish) { var serverPath = server.Key; - var token = server.Value; - symbolLog.AppendLine($"Publishing symbol packages to {serverPath}:"); - symbolLog.AppendLine( + var token = server.Value;; + Log.LogMessage(MessageImportance.High, $"Performing symbol publishing...\nSymbolServerPath : ${serverPath} \nExpirationInDays : {ExpirationInDays} \nConvertPortablePdbsToWindowsPdb : false \ndryRun: false \nTotal number of symbol files : {fileEntries.Length} "); try @@ -662,10 +656,7 @@ await PublishSymbolsHelper.PublishAsync( Log.LogError(ex.Message); } - symbolLog.AppendLine("Successfully published to Symbol Server."); - symbolLog.AppendLine(); - Log.LogMessage(MessageImportance.High, symbolLog.ToString()); - symbolLog.Clear(); + Log.LogMessage(MessageImportance.High, $"Successfully published to ${serverPath}."); } } else From d9716af59edb32bb5833f0c971a57b0dba016836 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 12 May 2021 07:24:09 -0700 Subject: [PATCH 2/2] Fix compile error --- .../src/PublishArtifactsInManifestBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs index 20e9c6e5496..dfa8dd31a45 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs @@ -476,7 +476,7 @@ await PublishSymbolsHelper.PublishAsync( } gatherSymbolPublishingTime.Stop(); - symbolLog.AppendLine( + Log.LogMessage(MessageImportance.High, $"Symbol publishing for {symbol} took {gatherSymbolPublishingTime.ElapsedMilliseconds / 1000.0} (seconds)"); }