Skip to content

Commit 01e74b0

Browse files
.NET: Harden dotnet-format workflow shell handling (#14201)
Minor robustness and hygiene improvements to how the dotnet-format workflow passes values to the shell. No functional change to the formatting behavior. --------- Copilot-Session: b0794c00-ed83-4259-8d12-26df4b836393
1 parent 7481cd0 commit 01e74b0

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎.github/workflows/dotnet-format.yml‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,14 @@ jobs:
5353
- name: Find csproj files
5454
id: find-csproj
5555
if: github.event_name != 'pull_request' || steps.changed-files.outputs.added_modified != '' || steps.changed-files.outcome == 'failure'
56+
env:
57+
ADDED_MODIFIED: ${{ steps.changed-files.outputs.added_modified }}
5658
run: |
5759
csproj_files=()
5860
exclude_files=("Experimental.Orchestration.Flow.csproj" "Experimental.Orchestration.Flow.UnitTests.csproj" "Experimental.Orchestration.Flow.IntegrationTests.csproj")
61+
set -f
5962
if [[ ${{ steps.changed-files.outcome }} == 'success' ]]; then
60-
for file in ${{ steps.changed-files.outputs.added_modified }}; do
63+
for file in $ADDED_MODIFIED; do
6164
echo "$file was changed"
6265
dir="./$file"
6366
while [[ $dir != "." && $dir != "/" && $dir != $GITHUB_WORKSPACE ]]; do
@@ -78,7 +81,8 @@ jobs:
7881
fi
7982
csproj_files=($(printf "%s\n" "${csproj_files[@]}" | sort -u))
8083
echo "Found ${#csproj_files[@]} unique csproj/slnx files: ${csproj_files[*]}"
81-
echo "::set-output name=csproj_files::${csproj_files[*]}"
84+
echo "csproj_files=${csproj_files[*]}" >> "$GITHUB_OUTPUT"
85+
set +f
8286
8387
- name: Pull container dotnet/sdk:${{ matrix.dotnet }}
8488
if: steps.find-csproj.outputs.csproj_files != ''
@@ -87,8 +91,11 @@ jobs:
8791
# This step will run dotnet format on each of the unique csproj files and fail if any changes are made
8892
- name: Run dotnet format
8993
if: steps.find-csproj.outputs.csproj_files != ''
94+
env:
95+
CSPROJ_FILES: ${{ steps.find-csproj.outputs.csproj_files }}
9096
run: |
91-
for csproj in ${{ steps.find-csproj.outputs.csproj_files }}; do
97+
set -f
98+
for csproj in $CSPROJ_FILES; do
9299
echo "Running dotnet format on $csproj"
93-
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"
100+
docker run --rm -v "$(pwd):/app" -w /app mcr.microsoft.com/dotnet/sdk:${{ matrix.dotnet }} dotnet format "$csproj" --verify-no-changes --verbosity diagnostic
94101
done

0 commit comments

Comments
 (0)