Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions dotnet/targets/Microsoft.Sdk.Mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,44 @@
Condition="'$(SdkIsDesktop)' != 'true'">
</Target>

<!--
***********************************************************************************************
DeployToDevice

Target that deploys an already-built app to a device or simulator.
This target is called by 'dotnet run' to support deployment without rebuilding.
It accepts the $(Device) property for device selection.

See: https://github.com/dotnet/sdk/blob/c164a9bc1246c48191fb780992530f0fe975141b/documentation/specs/dotnet-run-for-maui.md
***********************************************************************************************
-->
<Target Name="DeployToDevice"
DependsOnTargets="_DetectSdkLocations;_GenerateBundleName;_DetectAppManifest;ComputeAvailableDevices;_DeployToDevice"
Condition="'$(SdkIsMobile)' == 'true'" />

<Target Name="_DeployToDevice">
<Error Condition="$([MSBuild]::IsOSPlatform('windows'))" Text="It's currently not supported to deploy an app from the command line on Windows." />
<Error Condition="!Exists('$(_AppBundlePath)')" Text="The app must be built before it can be deployed. Could not find the app bundle at '$(_AppBundlePath)'." />

<GetMlaunchArguments
SessionId="$(BuildSessionId)"
AppManifestPath="$(_AppBundleManifestPath)"
DiscardedDevices="@(DiscardedDevices)"
Devices="@(Devices)"
DeviceName="$(Device)"
InstallApp="$(_AppBundlePath)"
MlaunchPath="$(MlaunchPath)"
SdkDevPath="$(_SdkDevPath)"
SdkIsSimulator="$(_SdkIsSimulator)"
SdkVersion="$(_SdkVersion)"
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
>
<Output TaskParameter="MlaunchArguments" PropertyName="_DeployToDeviceArguments" />
</GetMlaunchArguments>

<Exec Command="'$(MlaunchPath)' $(_DeployToDeviceArguments)" />
</Target>

<!--
***********************************************************************************************
ComputeAvailableDevices
Expand Down
Loading