Skip to content

[release/10.0.1xx] Fix working directory of simple file-based apps#53803

Merged
jjonescz merged 2 commits intorelease/10.0.1xxfrom
backport/pr-51828-to-release/10.0.1xx
Apr 11, 2026
Merged

[release/10.0.1xx] Fix working directory of simple file-based apps#53803
jjonescz merged 2 commits intorelease/10.0.1xxfrom
backport/pr-51828-to-release/10.0.1xx

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 10, 2026

Backport of #51828 to release/10.0.1xx

/cc @jjonescz

Description

Fixes a bug where dotnet run path/to/file.cs has a wrong working directory (it uses directory of the file, not the current working directory like usual for dotnet run). This only affects simple file-based apps (which skip MSBuild and invoke the C# compiler directly), hence it can be worked around with --no-cache (which skips this optimized path).

Customer impact

This was reported by several customers on GitHub. It has been fixed in 10.0.200 but it sill continues to be reported. Hence I think it would be good to backport this simple fix to 10.0.1xx.

Regression

Not since GA. This might have worked in some .NET 10 previews though (before we had the optimized path that introduced the bug).

Risk

Low. A simple change with narrow impact. Already released in 10.0.200. Unit test coverage.

@github-actions github-actions bot added the backport PR that has been backported to a servicing branch label Apr 10, 2026
@Youssef1313
Copy link
Copy Markdown
Member

it uses directory of the file, not the current working directory like usual for dotnet run.

The usual project-based dotnet run doesn't use the current working directory AFAIK. It uses RunWorkingDirectory MSBuild property. I didn't check what would it default to, but I thought it's worth noting. I'm not sure if the RunXYZ properties are relevant for you for file-based apps and if you want to respect them.

@jjonescz
Copy link
Copy Markdown
Member

it uses directory of the file, not the current working directory like usual for dotnet run.

The usual project-based dotnet run doesn't use the current working directory AFAIK. It uses RunWorkingDirectory MSBuild property. I didn't check what would it default to, but I thought it's worth noting. I'm not sure if the RunXYZ properties are relevant for you for file-based apps and if you want to respect them.

Yes, good point, they are respected. They default to the current working directory. And simple file-based apps cannot overwrite them (if they did, they wouldn't be simple anymore and would use msbuild and hence also RunWorkingDirectory). So using the current working directory is the correct default.

@jjonescz
Copy link
Copy Markdown
Member

/ba-g known: #53796, #53789

@jjonescz jjonescz merged commit 90c2460 into release/10.0.1xx Apr 11, 2026
22 of 26 checks passed
@jjonescz jjonescz deleted the backport/pr-51828-to-release/10.0.1xx branch April 11, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport PR that has been backported to a servicing branch Servicing-approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants