Skip to content

Commit 5f58b76

Browse files
[Xamarin.Android.Build.Tasks] move Console.WriteLine() messages to MSBuild log (#9359)
When running builds at the command-line (with the default, new "MSBuild Terminal Logger"), `Console.WriteLine()` output can make the text not look so great: > dotnet build -c Release -bl Restore complete (0.6s) You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy hellomaui _BuildApkEmbed (18.9s) Number of descriptors: 116; index entries: 232 hellomaui succeeded (33.3s) → bin\Release\net9.0-android\android-arm64\hellomaui.dll Build succeeded in 46.8s The message `Number of descriptors: 116; index entries: 232` appears, but so does another one. You can watch the terminal logger clear and rewrite messages, which is not ideal. Let's move these to the MSBuild logger, so they will show up in `.binlog` files, but not in the console output.
1 parent 04de4fe commit 5f58b76

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Xamarin.Android.Build.Tasks/Utilities/AssemblyStoreGenerator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,15 @@ string Generate (string baseOutputDirectory, AndroidTargetArch arch, List<Assemb
149149
WriteIndex (writer, mw, index, descriptors, is64Bit);
150150
mw.Flush ();
151151

152-
Console.WriteLine ($"Number of descriptors: {descriptors.Count}; index entries: {index.Count}");
153-
Console.WriteLine ($"Header size: {AssemblyStoreHeader.NativeSize}; index entry size: {IndexEntrySize ()}; descriptor size: {AssemblyStoreEntryDescriptor.NativeSize}");
152+
log.LogDebugMessage ($"Number of descriptors: {descriptors.Count}; index entries: {index.Count}");
153+
log.LogDebugMessage ($"Header size: {AssemblyStoreHeader.NativeSize}; index entry size: {IndexEntrySize ()}; descriptor size: {AssemblyStoreEntryDescriptor.NativeSize}");
154154

155155
WriteDescriptors (writer, descriptors);
156156
WriteNames (writer, infos);
157157
writer.Flush ();
158158

159159
if (fs.Position != (long)assemblyDataStart) {
160-
Console.WriteLine ($"fs.Position == {fs.Position}; assemblyDataStart == {assemblyDataStart}");
160+
log.LogDebugMessage ($"fs.Position == {fs.Position}; assemblyDataStart == {assemblyDataStart}");
161161
throw new InvalidOperationException ($"Internal error: store '{storePath}' position is different than metadata size after header write");
162162
}
163163

0 commit comments

Comments
 (0)