Fix potential InvalidOperationException in ProfilerLogger (#3981)
Fix potential InvalidOperationException in ProfilerLogger (#3981)

Fixes #3967.
Microsoft/msbuild,mono/msbuild,Microsoft/msbuild,cdmihai/msbuild,chipitsine/msbuild,AndyGerlicher/msbuild,rainersigwald/msbuild,rainersigwald/msbuild,cdmihai/msbuild,chipitsine/msbuild,mono/msbuild,chipitsine/msbuild,jeffkl/msbuild,sean-gilliam/msbuild,mono/msbuild,AndyGerlicher/msbuild,AndyGerlicher/msbuild,Microsoft/msbuild,cdmihai/msbuild,chipitsine/msbuild,AndyGerlicher/msbuild,jeffkl/msbuild,jeffkl/msbuild,rainersigwald/msbuild,rainersigwald/msbuild,mono/msbuild,sean-gilliam/msbuild,sean-gilliam/msbuild,jeffkl/msbuild,cdmihai/msbuild,sean-gilliam/msbuild,Microsoft/msbuild