[Xamarin.Android.Build.Tasks] implement dotnet run with an MSBuild target#9470
[Xamarin.Android.Build.Tasks] implement dotnet run with an MSBuild target#9470
dotnet run with an MSBuild target#9470Conversation
…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`.
| <RunCommand>dotnet</RunCommand> | ||
| <RunArguments>build "$(MSBuildProjectFullPath)" -target:Run --configuration "$(Configuration)"</RunArguments> |
There was a problem hiding this comment.
Note that before, we had no way to parse all the -p arguments passed to dotnet run through to the underlying Run target. We had $(Configuration) hardcoded here, but that was the only one that worked.
This comment was marked as outdated.
This comment was marked as outdated.
|
How will this effect the monodroid RunActivity and debugging system ? https://github.com/xamarin/monodroid/blob/main/tools/msbuild/Xamarin.Android.Common.Debugging.targets#L201 |
|
The new target here is only invoked by This won't affect any existing targets, but we could consider refactoring later to try to share more code. I couldn't reuse the |
|
What gives me pause is:
which I interpret as meaning "every I'm not sure that this is desirable? In a non-fastdev environment, I think Additionally, |
If we didn't do this, the app would never be installed. One example is:
It seems like we have to deploy? Otherwise, we need a "deployed" concept in the dotnet-cli.
If the |
Context: dotnet/sdk#42155
Context: dotnet/sdk#42240
Fixes: dotnet/sdk#31253
The .NET SDK has introduced a new
ComputeRunArgumentsMSBuild target that allows you to set$(RunCommand)and$(RunArguments)in a more dynamic way.So, on Android:
ComputeRunArgumentsdepends onInstall, so the app is deployed, the<FastDeploy/>MSBuild target runs, etc.$(RunCommand)is a path toadb$(RunArguments)is anshell am startcommand to launch the main activity.The new implementation also allows us to use the
-pparameter withdotnet run, such as:This will pass
-dtoadb, which allows you to select an attached device if an emulator is running.Previously, we had no way to pass
-parguments todotnet run.