-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Potential incrementality issue in GenerateTargetFrameworkMonikerAttribute #9840
Comments
After added
msbuild /t:SecondTarget doesn't output the secondtarget message. |
Thank you @JaynieBai ! I tried it out too and got the exact same result. This is because If we add Another solution could be to remove |
This is not quite right--it's more complicated :( The docs at https://learn.microsoft.com/en-us/visualstudio/msbuild/target-build-order?view=vs-2022#determine-the-target-build-order are accurate, but you have to read them about 300 times before they sink in. I did, anyway . . . What happens in your example is that the condition is evaluated between seeing the target for the first time (when the build starts, because you specified it as the entry-point target) and running the |
thanks Rainer! I wasn't looking forward to digging in deeper to understand this :) I'm going to bow out if you excuse me :) |
@surayya-MS can you try:
That should delay the evaluation of the condition to the point where it's already computed, so the target can be conditioned out rather than marked out of date. |
@rainersigwald I tested your suggestions in the PR https://github.com/dotnet/msbuild/pull/10934/files and the condition is still evaluated as false. Here is the log msbuild.binlog.txt |
msbuild/src/Tasks/Microsoft.Common.CurrentVersion.targets
Lines 3667 to 3689 in 9af8ff2
I think the problem is that the condition on the target doesn't match the condition on the WriteLinesToFile task. I think we should add
and '$(TargetFrameworkMonikerAssemblyAttributeText)' != ''
to the Condition on the Target.Otherwise we get this:
The target runs (because the output file doesn't exist), but then the tasks are skipped because the text is empty, and so it doesn't write the file again.
It's benign, but would be nice to get it out of the way for build incrementality investigations (the less targets run in an incremental build the easier it is to see targets which are breaking incrementality and shouldn't be running)
The text was updated successfully, but these errors were encountered: