Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cli/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -236,5 +236,9 @@ foreach ($PLATFORM in $PLATFORMS) {
}
}

# Kill extension processes again right before azd x build copies to ~/.azd/extensions/
# This prevents "file in use" errors during the install step
Stop-ExtensionProcesses

Write-Host "`n✓ Build completed successfully!" -ForegroundColor Green
Write-Host " Binaries are located in the $OUTPUT_DIR directory." -ForegroundColor Gray
4 changes: 4 additions & 0 deletions cli/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ for PLATFORM in "${PLATFORMS[@]}"; do
fi
done

# Kill extension processes again right before azd x build copies to ~/.azd/extensions/
# This prevents "file in use" errors during the install step
stop_extension_processes

echo ""
echo "✓ Build completed successfully!"
echo " Binaries are located in the $OUTPUT_DIR directory."
20 changes: 19 additions & 1 deletion cli/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func All() error {
func Build() error {
// Kill any running app processes first to avoid "file in use" errors on Windows
_ = killAppProcesses()
time.Sleep(500 * time.Millisecond)

mg.Deps(DashboardBuild)

Expand All @@ -129,7 +130,7 @@ func Build() error {
}

// Build and install directly using azd x build
if err := sh.RunWithV(env, "azd", "x", "build"); err != nil {
if err := runWithEnvRetry(env, "azd", "x", "build"); err != nil {
return fmt.Errorf(errBuildFailedFmt, err)
}

Expand All @@ -138,6 +139,23 @@ func Build() error {
return nil
}

// runWithEnvRetry runs a command with environment variables, retrying up to 3 times on failure.
func runWithEnvRetry(env map[string]string, cmd string, args ...string) error {
const maxRetries = 3
var err error
for i := 0; i < maxRetries; i++ {
if i > 0 {
delay := time.Duration(i*5) * time.Second
fmt.Printf(" ⚠️ Attempt %d/%d failed, retrying in %s...\n", i, maxRetries, delay)
time.Sleep(delay)
}
if err = sh.RunWithV(env, cmd, args...); err == nil {
return nil
}
}
return err
}

// buildAllPlatforms compiles the CLI binary for all platforms (used for releases).
func buildAllPlatforms() error {
fmt.Println("Building CLI for all platforms...")
Expand Down
Loading