-
Notifications
You must be signed in to change notification settings - Fork 533
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
[Xamarin.Android.Build.Tasks] implement dotnet run
with an MSBuild target
#9470
base: main
Are you sure you want to change the base?
Conversation
…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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Application.targets Lines 23 to 29 in 13b7378
|
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
ComputeRunArguments
MSBuild target that allows you to set$(RunCommand)
and$(RunArguments)
in a more dynamic way.So, on Android:
ComputeRunArguments
depends onInstall
, so the app is deployed, the<FastDeploy/>
MSBuild target runs, etc.$(RunCommand)
is a path toadb
$(RunArguments)
is anshell am start
command to launch the main activity.The new implementation also allows us to use the
-p
parameter withdotnet run
, such as:This will pass
-d
toadb
, which allows you to select an attached device if an emulator is running.Previously, we had no way to pass
-p
arguments todotnet run
.