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

Broken dependency 'chain' when a target in the middle of the chain fails the build #641

Open
baronfel opened this issue Dec 14, 2022 · 4 comments

Comments

@baronfel
Copy link
Contributor

baronfel commented Dec 14, 2022

I was just diagnosing a build where there was a long chain of targets. One of the 'internal' targets errors out, stopping the build. Here is a simplified diagram

A
| _ B
    | _ C -> Errors out, stopping the build
        | _ D
            | _ E -> Actual target requested by the build

In the log viewer, I can easily see the results of targets A, B, and C, including a nice link between C and B (and B and A) that shows the dependency relationships. However, the final result of my investigation was that D should not have been called at all, but the log viewer didn't (or wasn't able) to show be why C was triggered (and so on, why D was triggered), because the error at C stopped the rest of the build processing.

Does this information exist today? If so, how should/could it be displayed?

@KirillOsenkov
Copy link
Owner

Repro:

<Project>

  <Target Name="A">
  </Target>

  <Target Name="B" DependsOnTargets="A">
  </Target>

  <Target Name="C" DependsOnTargets="B">
    <Error Text="BOOM" />
  </Target>

  <Target Name="D" DependsOnTargets="C">
  </Target>

  <Target Name="E" DependsOnTargets="D">
  </Target>

  <Target Name="Build" DependsOnTargets="E">
  </Target>

</Project>

@KirillOsenkov
Copy link
Owner

We get 30 events during this build:

image

Unfortunately it looks like MSBuild doesn't send us enough information about the "stack" of targets being built.

I'd move this to dotnet/msbuild and we can design how we can send more information on TargetStartedEventArgs (other than the ParentTarget)

@KirillOsenkov
Copy link
Owner

See also:
dotnet/msbuild#4936

One way I see to solve this is when a target fails the build, we could emit a TargetSkippedEventArgs for each target currently on the stack and drain the stack. This would allow us to reconstruct the entire chain of missing links.

See related:
dotnet/msbuild#6528

@KirillOsenkov
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants