-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ToolTasks Don't Log MSB4181 When Terminated #6968
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e06a995
Tooltasks return !HasLoggedErrors when terminated
benvillalobos 61f1a3e
Revert "Tooltasks return !HasLoggedErrors when terminated"
benvillalobos 8598f27
Don't log MSB4181 when a task is cancelled.
benvillalobos 1650c0c
Tidy up MSB4181 conditions
benvillalobos 997c703
Add regression test
benvillalobos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely solves the problem but I'm not sure it's conceptually right: the task was cancelled before completion, so shouldn't it return
falseas inI did not succeed?Is the "was cancellation requested" state available at the time when we check failure/has-logged-error and log the new message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the code that logs the warning
https://github.com/dotnet/msbuild/blob/main/src/Utilities/ToolTask.cs#L939-L949
Can a task be cancelled outside of the user's control? That's not something I considered when writing this.
It really depends how we want to view this task. I see a tooltask being (manually) cancelled as "I didn't fail, so as long as I didn't log an error I'm good"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking more like wrapping a
if (!_cancellationToken.IsCancellationRequested)around the actual error message here:msbuild/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs
Lines 940 to 958 in a7d5790
(but I didn't validate that that actually worked).
My mental model for a task is "return
true: everything completed satisfactorily. returnfalse: something somewhere went wrong". But it's a bit ambiguous.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused here. The RemoveDir change is a good example. It used to return true only if all the directories were successfully deleted. That PR is pushing for having it return true even if some directories weren't deleted, so long as we didn't log an error. which is somewhere in the middle of
"return true: everything completed satisfactorily. return false: something somewhere went wrong"I like your suggested solution better though since it's less break-y, so I'll give that a shot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your idea works 🚀 and avoids a fundamental change to all tooltasks. Not exactly sure how to test this though, my local test runs a sleep.exe that wouldn't exist in a unit test. Any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a helper for that, try something like:
msbuild/src/Build.UnitTests/BackEnd/BuildManager_Tests.cs
Lines 1523 to 1533 in a7d5790