dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.21k stars 1.35k forks source link

VS Binlog has evaluations that don't include property/item data with MSBUILDLOGIMPORTS #10225

Closed rainersigwald closed 1 month ago

rainersigwald commented 3 months ago

I am in possession of a binlog that looks like this

image

So it did evaluation, including firing the import events AND EMBEDDING THE FILES but somehow didn't report post-evaluation item and property states?

AR-May commented 3 months ago

Have been able to reproduce the issue:

  1. Create a vcxproj console project from a VS template
  2. Open a cmd and set MSBUILDLOGIMPORTS and MSBUILDDEBUGENGINE environment variables.
  3. Open the solution from the same cmd: <path to devenv.exe> <solution_name>
  4. Run build
  5. Check MSBuild_Logs folder for binlogs with missing items and properties.
KirillOsenkov commented 3 months ago

Have we validated that @JanKrivanek's change actually fixes this?

Binlogs obtained from VS have always been deficient and missing info. The Project System Tools extension was especially bad, but even the MSBUILDDEBUGENGINE=1 mode produces no evaluation and I thought it's because CPS evaluates separately from builds.

See related:

I don't think MuxLogger is the problem. I have an environment where MuxLogger is present but still the binlogs have the full information.

KirillOsenkov commented 3 months ago

Another way to test this is set the env variable MSBUILDLOGPROPERTIESANDITEMSAFTEREVALUATION=1 and see if it fixes things. If it does then yes, it indicates a legacy logger is present.

But I suspect it won't fix it.

rainersigwald commented 3 months ago

Binlogs obtained from VS have always been deficient and missing info. The Project System Tools extension was especially bad, but even the MSBUILDDEBUGENGINE=1 mode produces no evaluation and I thought it's because CPS evaluates separately from builds.

there will be no evaluation in the logs of build, because it already happened, but there should be a log with evaluations in it, and this one seems to be that one . . . except they're incomplete.

KirillOsenkov commented 3 months ago

I've never understood how are evaluations separate from build? How is it implemented?

JanKrivanek commented 3 months ago

The ProjectInstance (or Project) can be created and evaluated standalone. They can then be used to issue build requests. That's how those 2 events get executed separately.

I'll double/triple check and debug the scenario next week (away from my devbox now) to confirm the theory.

JanKrivanek commented 1 month ago

Reopening as fix introduced VS perf regression - we will need to fix that one in coordination with the fix

JanKrivanek commented 1 month ago

We'll need to investigate the hidden root-cause, in order to prevent the perf regression after fix.

First we'll need to find stable repro - steps:

Check the binlog - evaluation result of a project should normally contain properties and items:

image

If they are missing - issue reproduces.

If issue doesn't reproduce, try:

Once repro is found, we'll need previous - unbroken instance

Once we have 2 versions to compare - we'll need to look into behavior differences

If any of the above steps doesn't work - please do not continue with further steps (as they might expect the previous steps are true) - instead we'll need to figure adjustment of investigation.

GangWang01 commented 1 month ago

No matter disabling msbuild in-proc node or not, this issue could be reproduced with older VS versions, even back to 17.0.0. VS 2019(16.11.38) also has this issue. It means this issue has existed for a long time.

With Jan's help, I looked into which loggers are registered and which of these call IEventSource4.IncludeEvaluationPropertiesAndItems() in Initialize(IEventSource eventSource) of the loggers through debugging with $env:MSBuildDebugBuildManagerOnStart="1". The registered loggers are:

JanKrivanek commented 1 month ago

Thank you @GangWang01! Let's dig more into why the fix for this causes perf regression - what are the other registered loggers in VS and what are their setting of IncludeEvaluationPropertiesAndItems?

GangWang01 commented 1 month ago

Enabling binary logger by setting $env:MSBUILDNOINPROCNODE="1" interfered the investigation. It didn't simulate the case in VS perf tests. Without enabling binary logger, I found the loggers below were registered that was different from the investigation.