From a8985f27470403cead3862d792b181a68c38cf9c Mon Sep 17 00:00:00 2001 From: Davis Goodin Date: Wed, 21 Jan 2026 12:12:31 -0800 Subject: [PATCH 1/2] Fix signing diag file consolidation: always run --- eng/_util/cmd/sign/archive.go | 24 ++++++++++-------------- eng/_util/cmd/sign/sign.go | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/eng/_util/cmd/sign/archive.go b/eng/_util/cmd/sign/archive.go index 1ee24fb7b27..fa18b0af2bf 100644 --- a/eng/_util/cmd/sign/archive.go +++ b/eng/_util/cmd/sign/archive.go @@ -9,6 +9,7 @@ import ( "archive/zip" "cmp" "context" + "errors" "fmt" "io" "io/fs" @@ -464,27 +465,25 @@ func (a *archive) copyToDestination(ctx context.Context) error { } func consolidateDiagnosticFiles() error { + // Do as much as possible, accumlating errors to report to the user. + var err error // Signing process logs. - if err := copyGlobFilesToDir( + err = errors.Join(err, copyGlobFilesToDir( *consolidateDiagDir, filepath.Join(*signingCsprojDir, "*.log"), filepath.Join(*tempDir, "*.binlog"), filepath.Join(*tempDir, "*.props"), - ); err != nil { - return err - } + )) // .NET diag data, for package versions etc. - if err := copyGlobFilesToDir( + err = errors.Join(err, copyGlobFilesToDir( filepath.Join(*consolidateDiagDir, "obj"), filepath.Join(*signingCsprojDir, "obj", "*"), - ); err != nil { - return err - } + )) // Signing working dirs. These contain the files actually sent to sign. Make // it clear that they're not production-ready files through the filename. cleanTempDir := filepath.Clean(*tempDir) - if err := withTarGzCreate( + err = errors.Join(err, withTarGzCreate( filepath.Join(*consolidateDiagDir, "sign-work-archives.nonproduction.tar.gz"), func(tw *tar.Writer) error { if err := filepath.WalkDir(cleanTempDir, func(path string, d fs.DirEntry, err error) error { @@ -531,9 +530,6 @@ func consolidateDiagnosticFiles() error { } return nil }, - ); err != nil { - return err - } - - return nil + )) + return err } diff --git a/eng/_util/cmd/sign/sign.go b/eng/_util/cmd/sign/sign.go index b324bc2297f..c0f5332dfe5 100644 --- a/eng/_util/cmd/sign/sign.go +++ b/eng/_util/cmd/sign/sign.go @@ -7,6 +7,7 @@ package main import ( "context" "crypto/sha256" + "errors" "flag" "fmt" "io" @@ -74,7 +75,7 @@ func main() { } } -func run() error { +func run() (err error) { // A context for timeout. This timeout is mainly here to make sure child MSBuild processes are // terminated. There are some ctx.Err() checks sprinkled into the Go code, but canceling // quickly during the packaging/repackaging work in Go is not currently important: the Go work @@ -88,6 +89,14 @@ func run() error { defer cancel() } + defer func() { + log.Println("Consolidating diagnostic files") + log.Printf("Consolidated diagnostic directory: %q", *consolidateDiagDir) + + consolidateErr := consolidateDiagnosticFiles() + err = errors.Join(err, consolidateErr) + }() + archives, err := findArchives(ctx, *filesGlob) if err != nil { return err @@ -174,13 +183,6 @@ func run() error { } } - log.Println("Consolidating diagnostic files") - log.Printf("Consolidated diagnostic directory: %q", *consolidateDiagDir) - - if err := consolidateDiagnosticFiles(); err != nil { - return err - } - return nil } From 84cc06e529ecc0533be6c53086c371a80d14dd69 Mon Sep 17 00:00:00 2001 From: Davis Goodin Date: Wed, 21 Jan 2026 12:36:05 -0800 Subject: [PATCH 2/2] Update eng/_util/cmd/sign/archive.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- eng/_util/cmd/sign/archive.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/_util/cmd/sign/archive.go b/eng/_util/cmd/sign/archive.go index fa18b0af2bf..b76451d3c6b 100644 --- a/eng/_util/cmd/sign/archive.go +++ b/eng/_util/cmd/sign/archive.go @@ -465,7 +465,7 @@ func (a *archive) copyToDestination(ctx context.Context) error { } func consolidateDiagnosticFiles() error { - // Do as much as possible, accumlating errors to report to the user. + // Do as much as possible, accumulating errors to report to the user. var err error // Signing process logs. err = errors.Join(err, copyGlobFilesToDir(