-
Notifications
You must be signed in to change notification settings - Fork 4
Figure out 'dotnet run' CLI experience for iOS and Android #26
Comments
Yes, there is a way, but it's not very user-friendly at the moment.
You can hit Enter to terminate the app. |
Thoughts from a stranger on the internet;
As for the commands and their expected outcomes... dotnet build
IMO under existing dotnet CLI behaviour this doesn't need to produce an app package, just something that can be run (there are ways to get code running on a target without needing something link an APK, handy for alternative deploy approaches like a certain now dead Xamarin debug app). A noted behaviour with Android deploys however is that it dumps an APK in dotnet run
There are 3 ways I've used this command.
|
@Silic0nS0ldier Good feedback, but I'm pretty sure that the experience that @rolfbjarne raises is very much an "at the moment" sort of issue. We'll get this sorted, and it will end up being very similar to what you've written.
I like this. Yes, the key task of |
What about that, you should specify emulator or target device when you call If there is no target device it should failed to run Ex |
Thanks for the tip, it works like a charm with the emulators. |
Try doing this for device:
if that doesn't work, please show the output. |
It's working, thanks ! |
msbuild.binlog.zip |
I believe you can work around that by executing this locally:
This is already fixed, and the problem should go away in a future preview (not sure if it'll be in preview7 or rc1). |
Using net6.0 (6.0.100) this command doesn't work.
Specifying it as |
I'm getting
When runninng
Any ideas how can I make MAUI app run on IOS device on my M1 mac ? |
@hflexgrig can you try getting a binlog (by passing |
What worked for me on Mac targeting iOS is this. The '-f net6.0-ios' part was necessary |
@rolfbjarne I'm getting the same issue as @hflexgrig, please find the binlog attached below (I had to change extension to upload here as binlog is not supported by Github, so please remove the .log part at the end of the filename) . The command I'm running is
I've also tried to add ```--self-contained" flag as it was giving me warning, but same result |
@anpin can you try changing |
@anpin Can you do a terminal cd into the directory rather than supplying the path to the solution? Please try that and include what I did above (your device UDID might differ). I had all trouble with even small variations of the script. |
@rolfbjarne after changing
and then finally
I also see a lot of compatibility warnings for
Please find the binlog here -> msbuild.binlog.log @lhughey running |
@anpin you need to remove the following line from your csproj: <MtouchArch>x86_64</MtouchArch> it conflicts with this line: <RuntimeIdentifier Condition="'$(TargetFramework)' == 'net6.0-ios'">ios-arm64</RuntimeIdentifier> If you want to build for the simulator (x86_64), you need to do this instead: <RuntimeIdentifier Condition="'$(TargetFramework)' == 'net6.0-ios'">iossimulator-x64</RuntimeIdentifier> |
@rolfbjarne sorry my bad, was copying configuration for signing from a working Xamarin.Forms project and overlooked this. I'm interested in having the app built and deployed on device, not simulator, so it builds without error after your sugestion, but deploy to device never starts. It hangs with
|
@anpin for running on device, omit the |
@rolfbjarne that did the job! Even though it crashed on startup, but I will file it elsewhere. The final command for running it on device looked like this
with following lines found in the
Thank you very much for your generous assistance. |
* MAUIに移行 とりあえずビルドに通るというだけの段階。現状だと、起動しようとすると落ちる。 * MacCatalystサポートを削除 ビルドエラーが起きるため * 不要な処理記述を削除 * アイコンファイル名を変え忘れていたので修正 * 不要な`SupportedOSPlatformVersion`指定を削除 * iPad実機でデバッグできるように設定を追加 ref: dotnet/xamarin#26 (comment) * XamarinからMauiに参照を修正 とりあえずこれでAndroidでは動作するようになった。 iPadだとまだブラックアウトする * iOSでうまく表示されないバグを修正 おそらくLaunchScreenを読み込めずに固まってた。 それ以外にも、念の為テンプレートで生成されるkey-valueも追加しておいた。 * MAUIにあわせてアセットの保存位置と読み込み方法を変更 * iOSでXAMLからmscorlibへの参照ができない場合があったので修正 * 不要な実装を削除 * iOSデバッグでリンカを走らせないように修正 XAMLのHotReloadと、ビルド時間の短縮のため * ファイル名ミスを修正 * Mapsui.Mauiを使用するためのおまじないを追加 SkiaSharpを初期化しないといけないため (Quickstart読むのをサボってた) * バージョン表示をFlyoutのFooterに追加 * 不要なRoute設定を削除 * Create appicon.svg とりあえず外周の丸だけを追加。 日本地図や飛行機、コンパス等は後で追加する * 飛行機アイコンを追加 * XMLフォーマットを修正 * コンパスを追加 * 日本地図を追加 * 白色での塗りつぶしを忘れていたので修正 * mergeでの消し忘れを修正 * migrate to maui / net6.0 * コードスタイルを修正 * 抜けていた半角スペースを追加 一応、ファイル内の表記と合わせた * Create CalloutText.cs 多段のテキストを表現するためのクラス * Create CustomTextCalloutPin.cs 自由なテキストを持てるCalloutを楽に扱うためのクラス * CustomCalloutを使う仕様に変更 MAUIでもSEGVが起きなくなった * Set Bundle Version to `1.0.11` * iOS Release用の設定を追加 * Paddingがおかしいバグを修正 Paddingの設定が、MAUIでは全方向で同じ値でないといけなくなったらしい。 * ButtonのMarginを調整 * Corner Radiusを設定 * MapをTapしてもCalloutが消えないバグを修正 * AndroidでSplashScreenの背景色がおかしくなっているバグを修正 * AndroidでAppIconが正常に表示されないバグを修正 iOSでアイコンが若干バグる * AdaptiveAppIcon対応に向け、Foregroundを分離 * Create appicon.svg * AppIconをsvgに変更 * MAUIにあわせてファイル配置を修正 (Custom Calloutのフォント設定)
Context: dotnet/xamarin#26 The following does not work as expected: dotnet new android dotnet run -c Release You end up with a `Debug` app in this case. The way we implemented `dotnet run` was to make `$(RunCommand)` and `$(RunArguments)` invoke `dotnet build -t:Run`. We were losing the `$(Configuration)` value in this example.
Context: dotnet/xamarin#26 The following does not work as expected: dotnet new android dotnet run -c Release You end up with a `Debug` app in this case. The way we implemented `dotnet run` was to make `$(RunCommand)` and `$(RunArguments)` invoke `dotnet build -t:Run`. We were losing the `$(Configuration)` value in this example. Update `Microsoft.Android.Sdk.Application.targets` so that `$(Configuration)` is forwarded to the `dotnet build -t:Run` command line.
For automated lookup of the UDID: This command picks the first iPhone device ID from the available list. Currently iPhone SE (3rd generation) in my case. dotnet build -t:Run -f net8.0-ios -p _DeviceName=:v2:udid:$(xcrun simctl list devices iPhone available | grep -om1 '[0-9A-F-]\{36\}') To select a specific device, update the search query. For iPhone 15: dotnet build -t:Run -f net8.0-ios -p _DeviceName=:v2:udid:$(xcrun simctl list devices 'iPhone 15' available | grep -om1 '[0-9A-F-]\{36\}') And since the simctl command lists out the devices usually in order with the most powerful devices last, you can also reverse the results, so it always picks the latest and greatest whenever Xcode updates. dotnet build -t:Run -f net8.0-ios -p _DeviceName=:v2:udid:$(xcrun simctl list devices iPhone available | tail -r | grep -om1 '[0-9A-F-]\{36\}') |
To run on a real device, using .NET 8 SDK I needed to specify dotnet build -t:Run -f net8.0-ios -p _DeviceName=00009999-000FFFFFFFFFFFFF -p:RuntimeIdentifier=ios-arm64 |
CLI experience
If you try the samples here, you can run iOS/Android projects at the command-line with:
iOS behavior
iOS launches the first simulator it finds in the list (which is currently an iPad) and prints the iOS console output at the command-line and blocks. You have to Ctrl+C to get the
dotnet
command to exit. You get an MSBuild error message after hitting Ctrl+C.@rolfbjarne feel free to chime in 😄, there might be a way to select which simulator you want.
Android behavior
Android uses the existing
adb
connection along with theAdbTarget
property if you need to select which device/emulator to use when there are multiple. Thedotnet
command exits successfully when the app is launched, giving no console output for the app.The Xamarin.Android SDK does not have any logic for locating emulators and launching them from MSBuild, as the IDEs do this for Android, currently. There is not any logic for giving
adb logcat
(console) output either.Can you
dotnet run
apps? Like.apk
,.aab
,.app
, or.ipa
files?There does not currently seem to be a way to do something like:
I think we would need some new behavior for the
dotnet run
command for this to be possible.--project
runs MSBuild, so that is why we were able to get this part to work.Conclusion
What should the behavior be here? Both iOS/Android behaviors are reasonable in their own way.
The text was updated successfully, but these errors were encountered: