-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,6 @@ This file contains targets specific for Android application projects. | |
<UseAppHost>false</UseAppHost> | ||
<!-- see: https://github.com/xamarin/xamarin-macios/blob/a6eb528197854c074d9dd5847328c096890337be/dotnet/targets/Xamarin.Shared.Sdk.props#L38-L52 --> | ||
<_RuntimeIdentifierUsesAppHost>false</_RuntimeIdentifierUsesAppHost> | ||
<RunCommand>dotnet</RunCommand> | ||
<RunArguments>build "$(MSBuildProjectFullPath)" -target:Run --configuration "$(Configuration)"</RunArguments> | ||
|
||
<!-- If Xamarin.Android.Common.Debugging.targets exists, we can rely on _Run for debugging. --> | ||
<_RunDependsOn Condition=" '$(_XASupportsFastDev)' == 'true' "> | ||
|
@@ -27,8 +25,29 @@ This file contains targets specific for Android application projects. | |
Install; | ||
StartAndroidActivity; | ||
</_RunDependsOn> | ||
<_AndroidComputeRunArgumentsDependsOn> | ||
Install; | ||
</_AndroidComputeRunArgumentsDependsOn> | ||
</PropertyGroup> | ||
|
||
<Target Name="_AndroidComputeRunArguments" | ||
BeforeTargets="ComputeRunArguments" | ||
DependsOnTargets="$(_AndroidComputeRunArgumentsDependsOn)"> | ||
<GetAndroidActivityName | ||
Condition=" '$(AndroidLaunchActivity)' == '' " | ||
ManifestFile="$(IntermediateOutputPath)android\AndroidManifest.xml"> | ||
<Output TaskParameter="ActivityName" PropertyName="AndroidLaunchActivity" /> | ||
</GetAndroidActivityName> | ||
<PropertyGroup> | ||
<RunCommand>$(AdbToolExe)</RunCommand> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Elsewhere, we support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should do at least two things:
<_AdbToolExe>$(AdbToolExe)</_AdbToolExe>
<_AdbToolExe Condition=" '$(_AdbToolExe)' == '' and $([MSBuild]::IsOSPlatform('windows')) ">adb.exe</_AdbToolExe>
<_AdbToolExe Condition=" '$(_AdbToolExe)' == '' and !$([MSBuild]::IsOSPlatform('windows')) ">adb</_AdbToolExe>
<RunCommand Condition=" '$(_AndroidSdkDirectory)' != '' ">$([System.IO.Path]::Combine($(_AndroidSdkDirectory), $(_AdbToolExe)))</RunCommand>
<RunCommand Condition=" '$(RunCommand)' == '' ">$(_AdbToolExe)</RunCommand> This way, we can still invoke |
||
<RunCommand Condition=" $(RunCommand) == '' and $([MSBuild]::IsOSPlatform('windows')) ">adb.exe</RunCommand> | ||
<RunCommand Condition=" $(RunCommand) == '' and !$([MSBuild]::IsOSPlatform('windows')) ">adb</RunCommand> | ||
<RunCommand>$([System.IO.Path]::Combine ('$(AdbToolPath)', '$(RunCommand)'))</RunCommand> | ||
<RunArguments>$(AdbTarget) shell am start -S -n "$(_AndroidPackage)/$(AndroidLaunchActivity)"</RunArguments> | ||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> | ||
</PropertyGroup> | ||
</Target> | ||
|
||
<Target Name="Run" DependsOnTargets="$(_RunDependsOn)" /> | ||
|
||
<PropertyGroup> | ||
|
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 todotnet run
through to the underlyingRun
target. We had$(Configuration)
hardcoded here, but that was the only one that worked.