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

AfterTargets build reason not shown #762

Open
JanKrivanek opened this issue Feb 29, 2024 · 2 comments
Open

AfterTargets build reason not shown #762

JanKrivanek opened this issue Feb 29, 2024 · 2 comments

Comments

@JanKrivanek
Copy link
Contributor

Description

The AfterTagets build reason is not being shown:

image

msbuild.zip

This seems to be quite consistent so I guess it's probably not an unexpected bug? But for some reason I haven't found similar feature request here

@KirillOsenkov
Copy link
Owner

All we get is a ParentTarget, which is null for Target4:
https://github.com/dotnet/msbuild/blob/cd64b7b4a690d809cf14fe2af807a328cce04e54/src/Framework/TargetStartedEventArgs.cs#L158

I'm guessing MSBuild should be setting ParentTarget to Target1 in this repro.

@KirillOsenkov
Copy link
Owner

And here's the logic that calculates the tooltip based on ParentTarget and TargetBuiltReason:

if (string.IsNullOrEmpty(ParentTarget))
{
return string.Empty;
}
if (OriginalNode != null)
{
return "Navigate to where the target was built originally";
}
if (TargetBuiltReason == TargetBuiltReason.None)
{
return $"{Name} was built because of {ParentTarget}";
}
var cause = TargetBuiltReason switch
{
TargetBuiltReason.AfterTargets => $"Target '{Name}' had AfterTargets='{ParentTarget}' directly or indirectly",
TargetBuiltReason.BeforeTargets => $"Target '{Name}' had BeforeTargets='{ParentTarget}'",
TargetBuiltReason.DependsOn => $"Target '{ParentTarget}' had DependsOnTargets='{Name}'",
_ => ""
};
return cause;

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

Successfully merging a pull request may close this issue.

2 participants