-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Extend the dotnet run
command discovery protocol to be settable by a Target instead of just Evaluation
#42155
Comments
Is this similar to what I filed here: |
This would be a step towards that, but not entirely that - making the command the SDK would invoke more pluggable without yielding the entire process-invocation pipeline to MSBuild (which might have constraints on e.g. terminal layout, etc.). If we had this issue implemented (which we may do based on needs from Azure Functions) as a small extension of the current 'run protocol' would MAUI be able to use this? Would there be certain targets that MAUI would want to run as part of generating the 'run command' that would influence what the Target dependency chain should be? |
Ok, slightly misread. Would it give a way to know the list of MSBuild properties passed to |
Ok, so I do think this feature could possibly solve some problems for MAUI (mobile platforms):
/cc @rolfbjarne |
For clarity - I've added to the spec above that calling this new target would be passed the same set of properties that were passed to the implicit build in step 3. |
@joj @sayedihashimi @javiercn I believe we're also interested in this functionality for running ASP.NET Core + JSPS projects from the command line instead of using the SpaProxy stuff, correct? |
We'll need to keep VS and C# Dev Kit in mind as they would also need to run the target to pick up the expected properties. The most straightforward thing to do would be to roll the It would help to have a |
Thanks @tmeschter - all of that sounds good to me. I'll update the description to include those notes. |
Yes, we would like to add support for |
Note that the run command might change depending on external factors (developer plugs in a new device for instance). The |
Right now, the MAUI extension in VSCode just runs |
FYI @jonathanpeppers, @sayedihashimi, @danroth27 and others this just merged and will be available starting in RC2. Nightlies for that starting tonight should enable use of the feature. In the simplest form, you'd create a Target with |
Nice! @joj @sayedihashimi Can you take a look at whether this new functionality enables moving the VS SPA templates to use this functionality instead of SpaProxy? @javiercn FYI. |
…target Context: dotnet/sdk#42155 Context: dotnet/sdk#42240 Fixes: dotnet/sdk#31253 The .NET SDK has introduced a new `ComputeRunArguments` MSBuild target that allows you to set `$(RunCommand)` and `$(RunArguments)` in a more dynamic way. So, on Android: * `ComputeRunArguments` depends on `Install`, so the app is deployed, the `<FastDeploy/>` MSBuild target runs, etc. * `$(RunCommand)` is a path to `adb` * `$(RunArguments)` is an `shell am start` command to launch the main activity. The new implementation also allows us to use the `-p` parameter with `dotnet run`, such as: dotnet run -bl -p:AdbTarget=-d This will pass `-d` to `adb`, which allows you to select an attached device if an emulator is running. Previously, we had no way to pass `-p` arguments to `dotnet run`.
Context: dotnet/sdk#31253 Context: dotnet/sdk#42155 Context: dotnet/sdk#42240 The .NET SDK has introduced a new `ComputeRunArguments` MSBuild target that allows you to set `$(RunCommand)` and `$(RunArguments)` in a more dynamic way. So, on Android: * `ComputeRunArguments` depends on `Install`, so the app is deployed, the `<FastDeploy/>` MSBuild target runs, etc. * `$(RunCommand)` is a path to `adb` * `$(RunArguments)` is an `shell am start` command to launch the main activity. The new implementation also allows us to use the `-p` parameter with `dotnet run`, such as: dotnet run -bl -p:AdbTarget=-d This will pass `-d` to `adb`, which allows you to select an attached device if an emulator is running. Previously, we had no way to pass `-p` arguments to `dotnet run`.
Is your feature request related to a problem? Please describe.
When running a project,
dotnet run
has a protocol that it implements to determine how to run the project:In a graphic this looks like:
This process relies on MSBuild evaluation to determine the RunCommand/RunArguments/RunWorkingDirectory, which means that these values can only be set during evaluation - no code or logic can run to influence their values. This can be highly limiting and means that use cases that need to run some dynamic logic to determine a value to put in the RunWorkingDirectory, for example, cannot be safely run.
Describe the solution you'd like
We should have an opt-in protocol that would allow
dotnet run
to invoke a target to get the RunCommand/RunArguments/RunWorkingDirectory data. This target should be public and documented and would update step 4 above as follows:a. if the project supports a ComputeRunCommand Target, then run that target and read the RunCommand/RunArguments/RunWorkingDirectory after target execution
b. otherwise read the same properties just after evaluation, as is done today
c. when called, this target would be passed all of the same MSBuild properties as applied to the implicit build in step 3
In a graphic this would look like:
Run Command Protocol
This new target would need to define its protocol
Opting-in
Projects would need to opt into the new behavior - the SDK currently computes the values here and so could change this for SDK-style projects as a default. Should there be a property-based opt-in, or should we just start doing this wholesale since the CLI and SDK targets change in lockstep?
Use cases like Azure Functions or MAUI may want to override the generation and so could override the target or set up a BeforeTargets, etc.
Compatibility
dotnet watch
command currently uses the RunCommand/RunArguments/RunWorkingDirectory as inputs toGenerateWatchList
- it will need to become aware of this target if necessary as well.Binlogs
We would to to ensure that if a binlog was requested that the configured binlog logger also applied to this new target, not just the implicit build + project evaluation for Run argument discovery
Additional context
@captainsafia for Aspire
@fabiocav for Functions
@jonathanpeppers for MAUI
@danroth27 for web
@tmat for watch
@tmeschter for project-system
The text was updated successfully, but these errors were encountered: