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

error MSB4017: The build stopped unexpectedly because of an unexpected logger failure. #7565

Closed
bouchraRekhadda opened this issue Apr 22, 2022 · 5 comments
Assignees
Labels
needs-triage Have yet to determine what bucket this goes in.

Comments

@bouchraRekhadda
Copy link

MSBuild 17.1.0 unable to use costume logger when maximum CPU is used (/m)

Starting from version 17.1.0 (more precisely 17.1.0.7609) MSBuild no longer capable of using a custom logger, that used to work with version 16.11.2

Steps to Reproduce

Sample reproduction repository can be found at bouchraRekhadda/ColorLogger.

  • MSBuild version: 17.1.0.7609
  • Visual Studio 2022: 17.1.0
  • Logger TFM: net48

Expected Behavior

Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
ColorLogger -> C:\Users\bouchraREKHADDA\source\repos\ColorLogger\bin\Debug\net48\ColorLogger.dll
Full log available in C:\Users\bouchraREKHADDA\AppData\Local\Temp\ColorLogger\msbuild_20220404-112128.log

Actual Behavior

MSBUILD : error MSB4017: The build stopped unexpectedly because of an unexpected logger failure.
Microsoft.Build.Exceptions.InternalLoggerException: The build stopped unexpectedly because of an unexpected logger failure. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Build.BackEnd.Logging.ParallelConsoleLogger.WriteMessageAligned(String message, Boolean prefixAlreadyWritten, Int32 prefixAdjustment)
at Microsoft.Build.BackEnd.Logging.ParallelConsoleLogger.PrintTargetNamePerMessage(BuildMessageEventArgs e, Boolean lightenText)
at Microsoft.Build.BackEnd.Logging.ParallelConsoleLogger.PrintMessage(BuildMessageEventArgs e, Boolean lightenText)
at Microsoft.Build.BackEnd.Logging.ParallelConsoleLogger.MessageHandler(Object sender, BuildMessageEventArgs e)
at Microsoft.Build.Logging.ConsoleLogger.MessageHandler(Object sender, BuildMessageEventArgs e)
at ColorLogger.ColorLogger.MessageHandler(Object sender, BuildMessageEventArgs e) in C:\Users\bouchraREKHADDA\source\repos\ColorLogger\ColorLogger.cs:line 140
at Microsoft.Build.Evaluation.ProjectCollection.ReusableLogger.MessageRaisedHandler(Object sender, BuildMessageEventArgs e)
at Microsoft.Build.BackEnd.Logging.EventSourceSink.RaiseMessageEvent(Object sender, BuildMessageEventArgs buildEvent)
--- End of inner exception stack trace ---
at Microsoft.Build.Exceptions.InternalLoggerException.Throw(Exception innerException, BuildEventArgs e, String
messageResourceName, Boolean initializationException, String[] messageArgs)
at Microsoft.Build.BackEnd.Logging.EventSourceSink.RaiseMessageEvent(Object sender, BuildMessageEventArgs buildEvent)
at Microsoft.Build.BackEnd.Logging.EventSourceSink.Consume(BuildEventArgs buildEvent)
at Microsoft.Build.BackEnd.Logging.EventSourceSink.Consume(BuildEventArgs buildEvent, Int32 sinkId)
at
Microsoft.Build.BackEnd.Logging.EventRedirectorToSink.Microsoft.Build.Framework.IEventRedirector.ForwardEvent(BuildEventArgs buildEvent)
at Microsoft.Build.BackEnd.Logging.CentralForwardingLogger.EventSource_AnyEventRaised(Object sender, BuildEventArgs buildEvent)
at Microsoft.Build.BackEnd.Logging.EventSourceSink.RaiseAnyEvent(Object sender, BuildEventArgs buildEvent)

Ask us questions

Originally asked in #4098 (comment)

@bouchraRekhadda bouchraRekhadda added the needs-triage Have yet to determine what bucket this goes in. label Apr 22, 2022
@bouchraRekhadda
Copy link
Author

Could you please update us on this issue ? it's currently blocking us from moving towards Visual Studio 2022 (and MSBuild 17)

@bouchraRekhadda
Copy link
Author

Hello @AR-May, could you please update us on this issue ?

@AR-May
Copy link
Member

AR-May commented May 9, 2022

Hello @bouchraRekhadda!
This seems to be a quite recent regression. MSBuild from VS 17.0 on my machine works well, but MSBuild from VS 2022 17.1 indeed fails. I, unfortunately, could not give any good workaround for this bug other than using the working version for the time being, if it agreeable for you.

I will take a look this week if there is a quick fix for this issue.

@bouchraRekhadda
Copy link
Author

bouchraRekhadda commented May 9, 2022

Changing the way we specify the maximum CPU count ColorLogger.cs#L81 with logger.Initialize(null, nodeCount) fixes the issue. (I am not sure though why we were specifying it that way -it's a legacy code-)

I'll close this issue. Feel free to reopen if you think there is a room for enhancement.

@bouchraRekhadda
Copy link
Author

Hello @AR-May,
Sorry I've closed the issue without refreshing the page, so I've missed your comment.
As I explained above, we have managed to workaround this issue. If you think there is maybe something to fix in MSBuild, you can reopen it.

Thank you in advance for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage Have yet to determine what bucket this goes in.
Projects
None yet
Development

No branches or pull requests

2 participants