Skip to content

Fix cross-platform path handling and env casing bug found testing ubuntu-latest - #1079

Merged
KevinJump merged 2 commits into
v17/mainfrom
fix/path-name-separator-crossplatform
Sep 8, 2026
Merged

KevinJump merged 2 commits into
v17/mainfrom
fix/path-name-separator-crossplatform

Conversation

@KevinJump

Copy link
Copy Markdown
Owner

Summary

While investigating whether the build/test workflows could move from windows-latest to ubuntu-latest runners (cheaper, and the code already targets net10.0 cross-platform), found and fixed two real bugs - both masked by Windows-specific behavior, unrelated to the actual runner-switch question:

  1. StringExtensions.ToAppSafeFileName didn't handle both path separators. It used Path.GetFileName/Path.GetDirectoryName, which only recognize the current OS's separator. A Windows-style path (backslashes) passed to this method on Linux was returned completely untouched instead of having app.config/web.config renamed, because GetFileName found no / to split on and returned the whole string, so the bad-name check never matched. Now splits on both \ and / manually so the result is the same regardless of which OS parses it. Caught by PathNameTests.BadFileNamesAreAppended, which failed on an ubuntu-latest test run but passes on windows-latest.

  2. env.Config casing bug in the "Generate AppSettings Schema" step, present in both dotnet-build.yml and package-build.yml. The env var is defined as config (lowercase), but this one step referenced ${{env.Config}}. This has silently worked forever because the Actions runner's env context is backed by the OS's real environment variables, and Windows env vars are case-insensitive - so it resolved fine on windows-latest. On ubuntu-latest the case-sensitive lookup returns nothing, -c ends up with no value, dotnet run swallows --project as if it were the value for -c, and the schema project is never found. Fixed both to use ${{ env.config }}.

Both were found and verified via throwaway test branches/PRs against ubuntu-latest (since closed/deleted) - after these two fixes, the full workflow ran green end-to-end on ubuntu-latest. This PR itself does not change the runner OS - windows-latest is unchanged here. Whether to actually switch runners is a separate decision now that these blockers are cleared.

Test plan

  • dotnet test passes locally (144/144, including the previously-failing PathNameTests)
  • Verified via a throwaway ubuntu-latest test PR that both fixes together produce a fully green run
  • Confirmed the fix doesn't change behavior on Windows (existing GoodFileNamesAreNotChanged/BadFileNamesAreAppended tests still pass unchanged)

🤖 Generated with Claude Code

KevinJump and others added 2 commits September 8, 2026 13:55
Path.GetFileName/GetDirectoryName only recognize the current OS's path
separator, so a Windows-style path (backslashes) passed to
ToAppSafeFileName on Linux was left completely untouched instead of
having app.config/web.config renamed - GetFileName returned the whole
string unchanged since there was no '/' to split on, so the bad-name
check never matched.

Discovered while testing whether the build/test workflows could move to
ubuntu-latest runners: PathNameTests.BadFileNamesAreAppended failed on
Linux for exactly this reason. Now splits on both '\' and '/' manually
so the result doesn't depend on which OS is parsing the path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Both workflows define the env var as 'config' (lowercase) but the
"Generate AppSettings Schema" step referenced it as \${{env.Config}}.
Windows silently masked this because the GitHub Actions runner backs
its env context with the OS's actual environment variables, and Windows
env vars are case-insensitive - so it resolved fine there. Found this
while verifying the ToAppSafeFileName fix would make the build/test
workflows pass on ubuntu-latest: on Linux the case-sensitive lookup
failed, the -c flag ended up with no value, and dotnet run swallowed
--project as the value instead, so the schema project was never found.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@KevinJump
KevinJump merged commit 4d4c248 into v17/main Sep 8, 2026
5 checks passed
@KevinJump
KevinJump deleted the fix/path-name-separator-crossplatform branch September 8, 2026 13:05
@KevinJump KevinJump mentioned this pull request Sep 8, 2026
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant