Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How gets RunArguments property evaluated? #32551

Open
maraf opened this issue May 16, 2023 · 7 comments
Open

How gets RunArguments property evaluated? #32551

maraf opened this issue May 16, 2023 · 7 comments
Assignees
Milestone

Comments

@maraf
Copy link
Member

maraf commented May 16, 2023

I would like to change RunArguments based on other property value

I have this snippet

<_RunExtraArguments Condition="'$(WasmEnableThreads)' == 'true'">--apply-cop-headers</_RunExtraArguments>
<RunArguments>&quot;$(_BlazorDevServerDll)&quot; --applicationpath &quot;$(TargetPath)&quot; $(_RunExtraArguments)</RunArguments>

If WasmEnableThreads property is set in the csproj, it works as expected (_RunExtraArguments is set to --apply-cop-headers).
But if I pass it as an agrument on command line dotnet run /p:WasmEnableThreads=true, the WasmEnableThreads property value is empty when RunArguments are computed.

Do you have any advice on how accomplish such use case?

@maraf maraf added the question label May 16, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-CLI untriaged Request triage from a team member labels May 16, 2023
@vitek-karas
Copy link
Member

The problem is that dotnet run doesn't process the arguments, it passes everything to the app. So in your example:
dotnet run /p:WasmEnableThreads=true the app will be executed with a command line parameter /p:WasmEnabledThreads=true.

I vaguely remember that there was an issue on this topic here already, but I can't find it right now.

@KalleOlaviNiemitalo
Copy link

AFAICT, in .NET SDK 7.0.105, dotnet run passes /p:WasmEnableThreads=true to the application, but processes -p:WasmEnableThreads=true or --property:WasmEnableThreads=true to set the property.

@maraf
Copy link
Member Author

maraf commented May 19, 2023

I tested it today with 8.0.100-preview.4.23220.2

  • /p:WasmEnableThreads=true is passed to the "run" process (as documentation says)
  • both -p:WasmEnableThreads=true and --property:WasmEnableThreads=true are ignored

I have a simple console project echoing arguments

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <RunCommand>cmd.exe</RunCommand>
    <RunArguments>/c &quot;echo '$(WasmEnableThreads)'&quot;</RunArguments>
  </PropertyGroup>
</Project>

The output is

C:\Development\samples\ConsoleSample>dotnet run /p:WasmEnableThreads=true
'' /p:WasmEnableThreads=true

C:\Development\samples\ConsoleSample>dotnet run -p:WasmEnableThreads=true
''

C:\Development\samples\ConsoleSample>dotnet run --property:WasmEnableThreads=true
''

Is it a regression?

@nagilson nagilson added needs team triage Requires a full team discussion and removed untriaged Request triage from a team member labels Jun 20, 2023
@baronfel
Copy link
Member

Here's what the behavior should be:

  • properties of all kinds (/p, -p, --property, etc) should be applied to
    • the (implicit) build of the project, if necessary
    • the evaluation of the project (to read RunCommand/RunArguments)
  • properties should not be applied to the application that is run
  • if a user wants the properties to be applied to the application that is run, they need to specify -- to signal that all tokens after the -- are forwarded to the application and not consumed by the run command.

@nagilson can you verify the first two points on preview5? If we're not applying the properties to the evaluation then we need to start doing so.

@dsplaisted
Copy link
Member

It looks like there are two problems:

  • We are not consistent about how we handle the different forms: /p, -p, or --property, ie whether we use them for the build or forward them to the application that is run. We should use them for the build in all these cases (unless they are after the -- separator).
  • We do not pass these global properties to the evaluation where we get the RunCommand and RunArguments properties. We should do this (in RunCommand.GetTargetCommand)

@pavelsavara
Copy link
Member

pavelsavara commented Jun 22, 2023

We have open WASM issue dotnet/runtime#85674 in which we also discuss how to also separate arguments to host VM and also mono VM. Possibly with multiple --

Host VM (not dotnet):
We are running inside NodeJS, browser or wasmtime VM, all of those have their own parameters. For example which env variables should be propagated into the VM, or which directories should be mounted.
I imagine that docker VM would be in the same category, if it becomes supported host.

Mono runtime (dotnet VM):
there are runtime flags would be good to set, usually to enable more logging, debugging, profiling.

Perhaps there should be pass-thru argument like --host:xxx=yyy and --runtime:aaa=bbb before application -- ? As an alternative to multiple --.

We considered some side channel, like runtimeconfig.json. It causes extra file download in browser. Extra FS access permissions in wasmtime which is not always possible. Also I'm not clear if passing runtime arguments to dotnet run should modify runtimeconfig.json file.

@radical
Copy link
Member

radical commented Jul 2, 2024

We do not pass these global properties to the evaluation where we get the RunCommand and RunArguments properties. We should do this (in RunCommand.GetTargetCommand)

Can we spin this off into a separate issue so it can be fixed independent of the discussion here?

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

No branches or pull requests

9 participants