Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xamarin.Android.Build.Tasks] fix enormous string expansion #4984

Merged

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Aug 6, 2020

Context: dotnet/msbuild#5553
Context: dotnet/msbuild#5315

I have seen some comically long log messages such as:

Task "GetDependsOnNETStandard" skipped, due to false condition; ('$(_HasReferenceToSystemRuntime)' != 'true' and '$(_IsXBuild)' != 'true' and '$(DependsOnNETStandard)' == '' and '@(_XACandidateNETStandardReferences)' != '') was evaluated as ('true' != 'true' and 'true' != 'true' and '' == '' and 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\Microsoft.CSharp.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\Microsoft.VisualBasic.Core.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\Microsoft.VisualBasic.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\Microsoft.Win32.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.AppContext.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Buffers.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.Concurrent.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.Immutable.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.NonGeneric.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.Specialized.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.Annotations.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.DataAnnotations.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.EventBasedAsync.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.TypeConverter.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Configuration.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Console.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Core.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Data.Common.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Data.DataSetExtensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Data.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Contracts.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Debug.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.DiagnosticSource.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.FileVersionInfo.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Process.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.StackTrace.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.TextWriterTraceListener.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Tools.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.TraceSource.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Tracing.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Drawing.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Drawing.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Dynamic.Runtime.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Formats.Asn1.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Globalization.Calendars.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Globalization.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Globalization.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Compression.Brotli.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Compression.FileSystem.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Compression.ZipFile.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Compression.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.FileSystem.DriveInfo.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.FileSystem.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.FileSystem.Watcher.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.FileSystem.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.IsolatedStorage.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.MemoryMappedFiles.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Pipes.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.UnmanagedMemoryStream.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Linq.Expressions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Linq.Parallel.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Linq.Queryable.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Linq.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Memory.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Http.Json.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Http.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.HttpListener.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Mail.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.NameResolution.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.NetworkInformation.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Ping.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Requests.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Security.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.ServicePoint.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Sockets.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebClient.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebHeaderCollection.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebProxy.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebSockets.Client.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebSockets.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Numerics.Vectors.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Numerics.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ObjectModel.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.DispatchProxy.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Emit.ILGeneration.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Emit.Lightweight.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Emit.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Metadata.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.TypeExtensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Resources.Reader.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Resources.ResourceManager.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Resources.Writer.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.CompilerServices.Unsafe.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.CompilerServices.VisualC.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Handles.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.InteropServices.JavaScript.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.InteropServices.RuntimeInformation.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.InteropServices.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Intrinsics.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Loader.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Numerics.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.Formatters.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.Json.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.Xml.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Claims.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.Algorithms.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.Csp.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.Encoding.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.X509Certificates.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Principal.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.SecureString.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ServiceModel.Web.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ServiceProcess.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Encoding.CodePages.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Encoding.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Encoding.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Encodings.Web.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Json.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.RegularExpressions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Channels.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Overlapped.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Tasks.Dataflow.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Tasks.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Tasks.Parallel.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Tasks.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Thread.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.ThreadPool.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Timer.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Transactions.Local.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Transactions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ValueTuple.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Web.HttpUtility.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Web.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Windows.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.Linq.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.ReaderWriter.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.Serialization.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XDocument.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XPath.XDocument.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XPath.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XmlDocument.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XmlSerializer.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\WindowsBase.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\mscorlib.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\netstandard.dll;C:\src\net5-samples\packages\microsoft.android.ref\11.0.100-ci.master.11\ref\net5.0\Java.Interop.dll;C:\src\net5-samples\packages\microsoft.android.ref\11.0.100-ci.master.11\ref\net5.0\Mono.Android.Export.dll;C:\src\net5-samples\packages\microsoft.android.ref\11.0.100-ci.master.11\ref\net5.0\Mono.Android.dll' != '').

This message is ~18K characters long.

This particular example has been around since PCL support was added
for Xamarin.Android.

There is a "fast path" in MSBuild that actually evaluating the
Condition will not expand the string when you compare against ''.
However, the string gets expanded anyway to produce the above log
message! At least it's not getting expanded twice?

The fix is to use ->Count() instead:

'@(_XACandidateNETStandardReferences->Count())' != '0'

Which prints a much shorter log message:

Task "GetDependsOnNETStandard" skipped, due to false condition; ('$(_HasReferenceToSystemRuntime)' != 'true' and '$(_IsXBuild)' != 'true' and '$(DependsOnNETStandard)' == '' and '@(_XACandidateNETStandardReferences->Count())' != '0') was evaluated as ('true' != 'true' and 'true' != 'true' and '' == '' and '156' != '0')

I fixed a similar message in Roslyn:

dotnet/roslyn#46445

Results

In a build with no changes:

> dotnet build .\HelloAndroid\HelloAndroid.csproj -bl -v:quiet

I could see a difference:

Project "HelloAndroid.csproj" (default targets): (1.024s)
Project "HelloAndroid.csproj" (default targets): (968ms)

The <GetDependsOnNETStandard/> MSBuild task runs 4 times in this
project because it is building for multiple $(RuntimeIdentifiers).

This saved ~56ms in one example, but it might not be noticeable at all
in "legacy" Xamarin.Android.

Down the road I will see if we can drop
Xamarin.Android.PCLSupport.targets completely for .NET 6 projects.

I went ahead and fixed any cases of '@(Foo)' != '' and updated
MSBuildBestPractices.md. The others would not likely be checking
against large item groups, but they could be.

@dellis1972
Copy link
Contributor

We are using this '@(xxxx)' != '' construct allot.

git grep " != ''" | grep "@"
MSBuild/Xamarin/Android/Xamarin.Android.Aapt2.targets:    Condition=" '$(_AndroidUseAapt2)' == 'True' And '@(_ProcessedCustomViews)' != '' ">
MSBuild/Xamarin/Android/Xamarin.Android.Aapt2.targets:      Condition=" '$(AndroidUseAapt2)' == 'True' And '@(_ItemsToFixup)' != '' "
MSBuild/Xamarin/Android/Xamarin.Android.Aapt2.targets:  <Touch Files="$(_AndroidResgenFlagFile)" AlwaysCreate="True" Condition=" '@(_UpdatedFlatFiles)' != '' " />
MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets:      Condition=" '$(UsingAndroidNETSdk)' != 'true' Or '@(InputJar)' != '' Or '@(EmbeddedJar)' != '' ">
MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets:      Condition=" '$(UsingAndroidNETSdk)' != 'true' Or '@(InputJar)' != '' Or '@(EmbeddedJar)' != '' "
MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Documentation.targets:      Condition=" '@(JavaDocIndex)' != '' And '$(_JavadocSupported)' == 'True' "
MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Microsoft.Cpp.Android.targets:               Condition="'$(BuildingSolutionFile)' == '' and '@(_NativeAndroidProjectReferenceWithoutConfiguration)' != ''" />
MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Microsoft.Cpp.Android.targets:               Condition="'@(_NativeAndroidProjectReferenceWithoutConfiguration)' != ''" />-->
MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Microsoft.Cpp.Android.targets:                 Condition="'@(_NativeAndroidProjectReferenceWithConfiguration)' != ''">
MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Microsoft.Cpp.Android.targets:        <MergeApkRecipelists RecipeFiles="%(_NativeAndroidRecipeFiles.Identity)" Condition="'@(_NativeAndroidRecipeFiles)' != '' And Exists('%(_NativeAndroidRecipeFiles.Identity)')">
MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Microsoft.Cpp.Android.targets:        <ItemGroup Condition="'@(NativeLibraryPaths)' != ''">
MSBuild/Xamarin/Android/Xamarin.Android.Wear.targets:      Condition=" $(AndroidApplication) And '@(_AppExtensionReference)' != '' "
Xamarin.Android.Common.targets:		<Compile Remove="@(CorrectCasedItem)" Condition=" '$(AndroidResgenFile)' != '' "/>
Xamarin.Android.Common.targets:		Condition=" '@(Content)' != '' "
Xamarin.Android.Common.targets:		<Compile Remove="@(CorrectCasedItem)" Condition=" '$(ManagedDesignTimeBuild)' == 'True' And '%(CorrectCasedItem.Identity)' != '' "/>
Xamarin.Android.Common.targets:	<Touch Files="$(_AndroidResFlagFile)" AlwaysCreate="True" Condition=" !Exists ('$(_AndroidResFlagFile)') Or  '@(_ModifiedResources)' != '' Or '@(_AndroidResourceDestRemovedFiles)' != '' " />
Xamarin.Android.Common.targets:    Condition=" '$(Language)' == 'C#' And ('$(AndroidGenerateLayoutBindings)' == 'True' Or '@(AndroidBoundLayout)' != '') ">
Xamarin.Android.Common.targets:	<ItemGroup Condition=" '@(_LayoutForBinding)' != '' ">
Xamarin.Android.Common.targets:	<ItemGroup Condition=" '@(_LayoutForBinding)' != '' ">
Xamarin.Android.Common.targets:	<ItemGroup Condition=" '@(_LayoutPartialClass)' != '' ">
Xamarin.Android.Common.targets:	Condition="@(AndroidInterfaceDescription) != ''"
Xamarin.Android.EmbeddedResource.targets:      Condition=" '$(AndroidApplication)' != 'true' And '@(EmbeddedNativeLibrary)' != '' "
Xamarin.Android.PCLSupport.targets:				Condition="'$(_HasReferenceToSystemRuntime)' != 'true' and '$(_IsXBuild)' != 'true' and '$(DependsOnNETStandard)' == '' and '@(_XACandidateNETStandardReferences)' != ''"
Xamarin.Android.Tooling.targets:      <_ResolveSdksFrameworkRefAssemblyPaths Include="@(ResolvedTargetingPack->'%(Path)\ref\%(TargetFramework)')" Condition=" '@(ResolvedTargetingPack)' == '@(FrameworkReference)' and '%(Identity)' != '' " />

might be worth cleaning that all up to use the faster option?

@jonathanpeppers
Copy link
Member Author

I should go ahead fix them all.

The one I fixed here was the only one I found generating a huge string. Doing something like:

> dotnet build HelloAndroid\HelloAndroid.csproj -v:diag | grep 'skipped, due to false condition' | code -

Then I scrolled through the list in VS Code and looked at the extremely long lines.

There might be others you can hit in large projects, or using different settings.

@jonathanpeppers jonathanpeppers marked this pull request as draft August 7, 2020 13:41
Context: dotnet/msbuild#5553
Context: dotnet/msbuild#5315

I have seen some comically long log messages such as:

    Task "GetDependsOnNETStandard" skipped, due to false condition; ('$(_HasReferenceToSystemRuntime)' != 'true' and '$(_IsXBuild)' != 'true' and '$(DependsOnNETStandard)' == '' and '@(_XACandidateNETStandardReferences)' != '') was evaluated as ('true' != 'true' and 'true' != 'true' and '' == '' and 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\Microsoft.CSharp.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\Microsoft.VisualBasic.Core.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\Microsoft.VisualBasic.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\Microsoft.Win32.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.AppContext.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Buffers.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.Concurrent.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.Immutable.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.NonGeneric.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.Specialized.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.Annotations.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.DataAnnotations.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.EventBasedAsync.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.TypeConverter.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Configuration.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Console.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Core.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Data.Common.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Data.DataSetExtensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Data.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Contracts.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Debug.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.DiagnosticSource.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.FileVersionInfo.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Process.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.StackTrace.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.TextWriterTraceListener.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Tools.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.TraceSource.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Tracing.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Drawing.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Drawing.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Dynamic.Runtime.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Formats.Asn1.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Globalization.Calendars.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Globalization.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Globalization.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Compression.Brotli.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Compression.FileSystem.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Compression.ZipFile.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Compression.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.FileSystem.DriveInfo.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.FileSystem.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.FileSystem.Watcher.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.FileSystem.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.IsolatedStorage.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.MemoryMappedFiles.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Pipes.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.UnmanagedMemoryStream.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Linq.Expressions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Linq.Parallel.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Linq.Queryable.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Linq.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Memory.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Http.Json.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Http.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.HttpListener.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Mail.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.NameResolution.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.NetworkInformation.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Ping.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Requests.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Security.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.ServicePoint.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Sockets.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebClient.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebHeaderCollection.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebProxy.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebSockets.Client.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebSockets.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Numerics.Vectors.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Numerics.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ObjectModel.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.DispatchProxy.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Emit.ILGeneration.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Emit.Lightweight.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Emit.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Metadata.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.TypeExtensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Resources.Reader.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Resources.ResourceManager.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Resources.Writer.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.CompilerServices.Unsafe.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.CompilerServices.VisualC.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Handles.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.InteropServices.JavaScript.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.InteropServices.RuntimeInformation.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.InteropServices.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Intrinsics.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Loader.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Numerics.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.Formatters.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.Json.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.Xml.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Claims.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.Algorithms.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.Csp.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.Encoding.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.X509Certificates.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Principal.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.SecureString.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ServiceModel.Web.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ServiceProcess.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Encoding.CodePages.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Encoding.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Encoding.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Encodings.Web.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Json.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.RegularExpressions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Channels.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Overlapped.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Tasks.Dataflow.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Tasks.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Tasks.Parallel.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Tasks.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Thread.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.ThreadPool.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Timer.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Transactions.Local.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Transactions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ValueTuple.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Web.HttpUtility.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Web.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Windows.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.Linq.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.ReaderWriter.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.Serialization.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XDocument.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XPath.XDocument.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XPath.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XmlDocument.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XmlSerializer.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\WindowsBase.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\mscorlib.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\netstandard.dll;C:\src\net5-samples\packages\microsoft.android.ref\11.0.100-ci.master.11\ref\net5.0\Java.Interop.dll;C:\src\net5-samples\packages\microsoft.android.ref\11.0.100-ci.master.11\ref\net5.0\Mono.Android.Export.dll;C:\src\net5-samples\packages\microsoft.android.ref\11.0.100-ci.master.11\ref\net5.0\Mono.Android.dll' != '').

This message is ~18K characters long.

This particular example has been around since PCL support was added
for Xamarin.Android.

There *is* a "fast path" in MSBuild that actually evaluating the
`Condition` will not expand the string when you compare against `''`.
However, the string gets expanded anyway to produce the above log
message! At least it's not getting expanded twice?

The fix is to use `->Count()` instead:

    '@(_XACandidateNETStandardReferences->Count())' != '0'

Which prints a much shorter log message:

    Task "GetDependsOnNETStandard" skipped, due to false condition; ('$(_HasReferenceToSystemRuntime)' != 'true' and '$(_IsXBuild)' != 'true' and '$(DependsOnNETStandard)' == '' and '@(_XACandidateNETStandardReferences->Count())' != '0') was evaluated as ('true' != 'true' and 'true' != 'true' and '' == '' and '156' != '0')

I fixed a similar message in Roslyn:

dotnet/roslyn#46445

~~ Results ~~

In a build with no changes:

    > dotnet build .\HelloAndroid\HelloAndroid.csproj -bl -v:quiet

I could see a difference:

    Project "HelloAndroid.csproj" (default targets): (1.024s)
    Project "HelloAndroid.csproj" (default targets): (968ms)

The `<GetDependsOnNETStandard/>` MSBuild task runs 4 times in this
project because it is building for multiple `$(RuntimeIdentifiers)`.

This saved ~56ms in one example, but it might not be noticeable at all
in "legacy" Xamarin.Android.

Down the road I will see if we can drop
`Xamarin.Android.PCLSupport.targets` completely for .NET 6 projects.

I went ahead and fixed any cases of `'@(Foo)' != ''` and updated
`MSBuildBestPractices.md`. The others would not likely be checking
against large item groups, but they could be.
@dellis1972
Copy link
Contributor

We can do it in another PR if you want. I don't mind

@jonathanpeppers jonathanpeppers marked this pull request as ready for review August 7, 2020 14:12
@jonathanpeppers
Copy link
Member Author

I fixed them all except for the ones in Microsoft.Cpp.Android.targets. I'm not sure we have great testing around those targets, so I'd rather not change them.

@dellis1972 dellis1972 merged commit 51d1da7 into dotnet:master Aug 10, 2020
@jonathanpeppers jonathanpeppers deleted the fix-msbuild-string-expansion branch August 10, 2020 13:02
jonpryor pushed a commit that referenced this pull request Aug 10, 2020
Context: dotnet/msbuild#5553
Context: dotnet/msbuild#5315

I have seen some comically long log messages such as:

    Task "GetDependsOnNETStandard" skipped, due to false condition; ('$(_HasReferenceToSystemRuntime)' != 'true' and '$(_IsXBuild)' != 'true' and '$(DependsOnNETStandard)' == '' and '@(_XACandidateNETStandardReferences)' != '') was evaluated as ('true' != 'true' and 'true' != 'true' and '' == '' and 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\Microsoft.CSharp.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\Microsoft.VisualBasic.Core.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\Microsoft.VisualBasic.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\Microsoft.Win32.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.AppContext.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Buffers.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.Concurrent.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.Immutable.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.NonGeneric.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.Specialized.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Collections.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.Annotations.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.DataAnnotations.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.EventBasedAsync.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.TypeConverter.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ComponentModel.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Configuration.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Console.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Core.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Data.Common.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Data.DataSetExtensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Data.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Contracts.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Debug.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.DiagnosticSource.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.FileVersionInfo.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Process.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.StackTrace.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.TextWriterTraceListener.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Tools.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.TraceSource.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Diagnostics.Tracing.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Drawing.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Drawing.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Dynamic.Runtime.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Formats.Asn1.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Globalization.Calendars.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Globalization.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Globalization.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Compression.Brotli.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Compression.FileSystem.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Compression.ZipFile.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Compression.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.FileSystem.DriveInfo.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.FileSystem.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.FileSystem.Watcher.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.FileSystem.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.IsolatedStorage.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.MemoryMappedFiles.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.Pipes.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.UnmanagedMemoryStream.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.IO.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Linq.Expressions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Linq.Parallel.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Linq.Queryable.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Linq.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Memory.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Http.Json.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Http.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.HttpListener.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Mail.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.NameResolution.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.NetworkInformation.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Ping.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Requests.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Security.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.ServicePoint.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.Sockets.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebClient.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebHeaderCollection.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebProxy.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebSockets.Client.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.WebSockets.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Net.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Numerics.Vectors.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Numerics.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ObjectModel.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.DispatchProxy.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Emit.ILGeneration.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Emit.Lightweight.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Emit.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Metadata.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.TypeExtensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Reflection.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Resources.Reader.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Resources.ResourceManager.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Resources.Writer.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.CompilerServices.Unsafe.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.CompilerServices.VisualC.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Handles.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.InteropServices.JavaScript.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.InteropServices.RuntimeInformation.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.InteropServices.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Intrinsics.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Loader.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Numerics.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.Formatters.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.Json.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.Xml.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.Serialization.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Runtime.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Claims.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.Algorithms.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.Csp.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.Encoding.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.Primitives.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Cryptography.X509Certificates.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.Principal.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.SecureString.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Security.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ServiceModel.Web.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ServiceProcess.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Encoding.CodePages.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Encoding.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Encoding.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Encodings.Web.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.Json.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Text.RegularExpressions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Channels.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Overlapped.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Tasks.Dataflow.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Tasks.Extensions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Tasks.Parallel.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Tasks.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Thread.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.ThreadPool.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.Timer.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Threading.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Transactions.Local.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Transactions.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.ValueTuple.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Web.HttpUtility.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Web.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Windows.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.Linq.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.ReaderWriter.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.Serialization.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XDocument.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XPath.XDocument.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XPath.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XmlDocument.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.XmlSerializer.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.Xml.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\System.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\WindowsBase.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\mscorlib.dll;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-rc.1.20371.13\ref\net5.0\netstandard.dll;C:\src\net5-samples\packages\microsoft.android.ref\11.0.100-ci.master.11\ref\net5.0\Java.Interop.dll;C:\src\net5-samples\packages\microsoft.android.ref\11.0.100-ci.master.11\ref\net5.0\Mono.Android.Export.dll;C:\src\net5-samples\packages\microsoft.android.ref\11.0.100-ci.master.11\ref\net5.0\Mono.Android.dll' != '').

This message is ~18K characters long.

This particular example has been around since PCL support was added
for Xamarin.Android.

There *is* a "fast path" in MSBuild that actually evaluating the
`Condition` will not expand the string when you compare against `''`.
However, the string gets expanded anyway to produce the above log
message! At least it's not getting expanded twice?

The fix is to use `->Count()` instead:

    '@(_XACandidateNETStandardReferences->Count())' != '0'

Which prints a much shorter log message:

    Task "GetDependsOnNETStandard" skipped, due to false condition; ('$(_HasReferenceToSystemRuntime)' != 'true' and '$(_IsXBuild)' != 'true' and '$(DependsOnNETStandard)' == '' and '@(_XACandidateNETStandardReferences->Count())' != '0') was evaluated as ('true' != 'true' and 'true' != 'true' and '' == '' and '156' != '0')

I fixed a similar message in Roslyn:

dotnet/roslyn#46445

~~ Results ~~

In a build with no changes:

    > dotnet build .\HelloAndroid\HelloAndroid.csproj -bl -v:quiet

I could see a difference:

    Project "HelloAndroid.csproj" (default targets): (1.024s)
    Project "HelloAndroid.csproj" (default targets): (968ms)

The `<GetDependsOnNETStandard/>` MSBuild task runs 4 times in this
project because it is building for multiple `$(RuntimeIdentifiers)`.

This saved ~56ms in one example, but it might not be noticeable at all
in "legacy" Xamarin.Android.

Down the road I will see if we can drop
`Xamarin.Android.PCLSupport.targets` completely for .NET 6 projects.

I went ahead and fixed any cases of `'@(Foo)' != ''` and updated
`MSBuildBestPractices.md`. The others would not likely be checking
against large item groups, but they could be.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants