Fix cross-platform path handling and env casing bug found testing ubuntu-latest - #1079
Merged
Merged
Conversation
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>
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While investigating whether the build/test workflows could move from
windows-latesttoubuntu-latestrunners (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:StringExtensions.ToAppSafeFileNamedidn't handle both path separators. It usedPath.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 havingapp.config/web.configrenamed, becauseGetFileNamefound 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 byPathNameTests.BadFileNamesAreAppended, which failed on an ubuntu-latest test run but passes on windows-latest.env.Configcasing bug in the "Generate AppSettings Schema" step, present in bothdotnet-build.ymlandpackage-build.yml. The env var is defined asconfig(lowercase), but this one step referenced${{env.Config}}. This has silently worked forever because the Actions runner'senvcontext is backed by the OS's real environment variables, and Windows env vars are case-insensitive - so it resolved fine onwindows-latest. Onubuntu-latestthe case-sensitive lookup returns nothing,-cends up with no value,dotnet runswallows--projectas 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 onubuntu-latest. This PR itself does not change the runner OS -windows-latestis unchanged here. Whether to actually switch runners is a separate decision now that these blockers are cleared.Test plan
dotnet testpasses locally (144/144, including the previously-failingPathNameTests)ubuntu-latesttest PR that both fixes together produce a fully green runGoodFileNamesAreNotChanged/BadFileNamesAreAppendedtests still pass unchanged)🤖 Generated with Claude Code