Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] move Console.WriteLine() messages to …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
jonathanpeppers authored Oct 2, 2024
1 parent 04de4fe commit 5f58b76
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ string Generate (string baseOutputDirectory, AndroidTargetArch arch, List<Assemb
WriteIndex (writer, mw, index, descriptors, is64Bit);
mw.Flush ();

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

WriteDescriptors (writer, descriptors);
WriteNames (writer, infos);
writer.Flush ();

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

Expand Down

0 comments on commit 5f58b76

Please sign in to comment.