File-based apps: consider args in simple csc optimization#50779
File-based apps: consider args in simple csc optimization#50779jjonescz merged 2 commits intodotnet:release/10.0.1xxfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
Fixes an issue where file-based C# apps were not properly passing command-line arguments when using the CSC optimization path. The PR ensures that when dotnet run uses the direct CSC compilation approach for file-based apps, the application arguments are correctly forwarded to the executed program.
- Modifies the
CreateCommandForCscBuiltProgrammethod to accept and properly escape application arguments - Updates the method call site to pass the
ApplicationArgsparameter - Adds comprehensive test coverage for the CSC-only path with arguments
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Cli/dotnet/Commands/Run/RunCommand.cs | Updates CSC optimization path to properly handle application arguments |
| test/dotnet.Tests/CommandTests/Run/RunFileTests.cs | Adds test cases to verify argument passing works correctly in CSC-only scenarios |
|
@333fred for a review of a simple change, thanks |
| var programPath = Path.Join(testInstance.Path, "Program.cs"); | ||
|
|
||
| var code = $""" | ||
| #:property Configuration=Release |
There was a problem hiding this comment.
What's the purpose of this flag in this test?
There was a problem hiding this comment.
To ensure we are testing the "CSC-only after MSBuild" optimization. Without this directive, the program could be built with CSC directly from the start (via hard-coded CSC args). That is already tested in the other test added in this PR. With any #: directive, the program needs to be built using MSBuild first (caching the CSC args) and only subsequent rebuilds can use CSC directly.
There was a problem hiding this comment.
Consider leaving a comment to that effect.
There was a problem hiding this comment.
It's part of a series of tests CscOnly_AfterMSBuild_* which all look similar to this one. I can add some comment to the first test, or maybe all of them, to explain it though.
Fixes #50778.