Skip to content

Tar archive creation silently ignores errors #16503

@MichaelSimons

Description

@MichaelSimons

Problem

In archives.targets, the tar commands for creating .tar.gz archives have IgnoreExitCode="true" and IgnoreStandardErrorWarningFormat="true":

<Exec Command="tar -czf &quot;$(_DestinationFileName)&quot; ."                                                                                                      
      IgnoreExitCode="true"                                                                                                                                         
      IgnoreStandardErrorWarningFormat="true"                                                                                                                       
      WorkingDirectory="$(_OutputPathRoot)"                                                                                                                         
      Condition="'$(_CurrentArchiveFormat)' == 'tar.gz' and '$(_PigzFoundExitCode)' != '0'"/>

This causes tar failures to be silently ignored.

Impact

  • Failed archive creation goes unnoticed
  • Missing archives aren't caught until downstream consumers fail
  • Difficult to diagnose because the build appears successful

Proposed Solution

  1. Remove IgnoreExitCode="true" and IgnoreStandardErrorWarningFormat="true" from the tar commands
  2. Let tar failures fail the build so issues are caught immediately
  3. If there are legitimate cases where tar errors should be ignored, those should be handled explicitly rather than blanket-ignoring all errors

Affected Code

  • src/arcade/src/Microsoft.DotNet.Build.Tasks.Archives/build/archives.targets- This applies to both the normal archive creation logic as well as the symbol archives

Questions to Investigate

  • Why were these flags added originally? Is there a scenario where tar "failing" is expected/acceptable?
  • Are there cases where tar outputs warnings to stderr that shouldn't fail the build?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions