From 3cc511f0ca8d73905edbfded1632fbae9e22e133 Mon Sep 17 00:00:00 2001 From: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com> Date: Tue, 30 Jun 2026 12:08:29 +0100 Subject: [PATCH] .NET: Harden dotnet-format workflow shell handling (#6796) * Harden dotnet-format workflow shell handling Minor robustness improvements to how the dotnet-format workflow passes values to the shell. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Refine workflow path handling Adjust shell settings around workflow path iteration for more predictable behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/dotnet-format.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dotnet-format.yml b/.github/workflows/dotnet-format.yml index b9672967e..13614ce30 100644 --- a/.github/workflows/dotnet-format.yml +++ b/.github/workflows/dotnet-format.yml @@ -54,11 +54,14 @@ jobs: - name: Find csproj files id: find-csproj if: github.event_name != 'pull_request' || steps.changed-files.outputs.added_modified != '' || steps.changed-files.outcome == 'failure' + env: + ADDED_MODIFIED: ${{ steps.changed-files.outputs.added_modified }} run: | csproj_files=() exclude_files=("Experimental.Orchestration.Flow.csproj" "Experimental.Orchestration.Flow.UnitTests.csproj" "Experimental.Orchestration.Flow.IntegrationTests.csproj") + set -f if [[ ${{ steps.changed-files.outcome }} == 'success' ]]; then - for file in ${{ steps.changed-files.outputs.added_modified }}; do + for file in $ADDED_MODIFIED; do echo "$file was changed" dir="./$file" while [[ $dir != "." && $dir != "/" && $dir != $GITHUB_WORKSPACE ]]; do @@ -80,6 +83,7 @@ jobs: csproj_files=($(printf "%s\n" "${csproj_files[@]}" | sort -u)) echo "Found ${#csproj_files[@]} unique csproj/slnx files: ${csproj_files[*]}" echo "csproj_files=${csproj_files[*]}" >> $GITHUB_OUTPUT + set +f - name: Pull container dotnet/sdk:${{ matrix.dotnet }} if: steps.find-csproj.outputs.csproj_files != '' @@ -88,8 +92,11 @@ jobs: # This step will run dotnet format on each of the unique csproj files and fail if any changes are made - name: Run dotnet format if: steps.find-csproj.outputs.csproj_files != '' + env: + CSPROJ_FILES: ${{ steps.find-csproj.outputs.csproj_files }} run: | - for csproj in ${{ steps.find-csproj.outputs.csproj_files }}; do + set -f + for csproj in $CSPROJ_FILES; do echo "Running dotnet format on $csproj" - docker run --rm -v $(pwd):/app -w /app mcr.microsoft.com/dotnet/sdk:${{ matrix.dotnet }} /bin/sh -c "dotnet format $csproj --verify-no-changes --verbosity diagnostic" + docker run --rm -v "$(pwd):/app" -w /app mcr.microsoft.com/dotnet/sdk:${{ matrix.dotnet }} dotnet format "$csproj" --verify-no-changes --verbosity diagnostic done