Skip to content

ToolTasks Can Log MSB4181 When Cancelled #5508

Closed

Description

Steps to reproduce

Assume there is a tool named "sleep" in the path. Build this project, then hit Ctrl-C.

<Project>

  <Target Name="t">
    <Exec Command="sleep 1000000"/>
  </Target>

</Project>

Actual behavior

C:\proj>dotnet msbuild test.proj
Microsoft (R) Build Engine version 16.7.0-preview-20330-08+96403c598 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

Attempting to cancel the build...
C:\proj\test.proj(4,5): warning MSB5021: Terminating the task executable "cmd" and its child processes because the build was canceled.
C:\proj\test.proj(4,5): error MSB4181: The "Exec" task returned false but did not log an error.

Expected behavior

If the task was canceled, suppress MSB4181.

MSB4181 is a grumble that the task does not follow the contract of "return false if an only if you logged an error". But in the case of cancelation, this error is useless for the user, who just hit Ctrl-C, and for the task author, who returned immediately exactly as the engine required them to. We don't want task authors to start logging bogus errors on cancelation. Just continue and fail the build with MSB4188: Build was canceled in the normal way.

Environment data

C:\proj>dotnet msbuild /version
Microsoft (R) Build Engine version 16.7.0-preview-20330-08+96403c598 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

16.7.0.33008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Area: DebuggabilityIssues impacting the diagnosability of builds, including logging and clearer error messages.Area: TasksIssues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll.For considerationUsed for items on the backlog to raise them to the top of that list for discussiontriaged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions