Skip to content

$(RunCommand) quoting #54917

Open
Open

Description

@rolfbjarne

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:

<!-- 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

  1. added
    untriaged
    on Jun 22, 2026
  2. jjonescz commented on Jun 22, 2026

    @jjonescz
    Member

    I think dotnet run is also passing $(RunCommand) directly to Process.Start():

    CommandSpec commandSpec = new(runProperties.Command, runProperties.Arguments);

    That Run target is probably only used if you do dotnet build /t:Run.

  3. added
    Area-Run
    on Jun 22, 2026
  4. jonathanpeppers commented on Jun 22, 2026

    @jonathanpeppers
    Member

    @baronfel do you have an opinion on what we should do? I think this breaks dotnet test on iOS, for example.

  5. baronfel commented on Jun 22, 2026

    @baronfel
    Member

    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 RunCommand should be just an single executable - that's the safer interpretation. Any other arguments should be RunArguments to that command. We're suffering a bit from some legacy naming here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-NetSDKArea-Rununtriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions