Repository navigation
Description
Is $(RunCommand) supposed to be the path to an executable, or just a general shell-executed string to run?
This matters, because it determines whether $(RunCommand) must be quoted if it contains spaces (or other shell-interpreted characters).
The Run target uses MSBuild's Exec task:
sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets
Lines 1462 to 1465 in b489ab2
| <!-- Override MSBuild Run Target --> | |
| <Target Name="Run" DependsOnTargets="ComputeRunArguments"> | |
| <Exec Command="$(RunCommand) $(RunArguments)" WorkingDirectory="$(RunWorkingDirectory)"/> | |
| </Target> |
which means that according to this implementation, $(RunCommand) is a general shell-executed string, and if something needs quoting, the $(RunCommand) variable must contain those quotes.
However, dotnet test passes $(RunCommand directly to Process.Start():
| FileName = Module.RunProperties.Command, |
and if this is how it's supposed to be, then $(RunCommand) is the path to an executable on disk, and must not be quoted.
So which is it?
And then the wrong implementation would need to be updated to follow the spec.
Activity
jjonescz commentedon Jun 22, 2026
I think
dotnet runis also passing$(RunCommand)directly toProcess.Start():sdk/src/Cli/dotnet/Commands/Run/RunCommand.cs
Line 642 in 3d73390
That
Runtarget is probably only used if you dodotnet build /t:Run.jonathanpeppers commentedon Jun 22, 2026
@baronfel do you have an opinion on what we should do? I think this breaks
dotnet teston iOS, for example.baronfel commentedon Jun 22, 2026
It's a tire fire, yeah - I wanted to expand the exec command to have a proper separation between executable path and argv array as separate inputs, but I haven't been able to get that merged yet.
IMO
RunCommandshould be just an single executable - that's the safer interpretation. Any other arguments should beRunArgumentsto that command. We're suffering a bit from some legacy naming here.[dotnet] Don't quote the 'RunCommand' property. (#25764)
[dotnet] Don't quote the 'RunCommand' property. (#25764)