Skip to content
Open
Show file tree
Hide file tree
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
133 changes: 133 additions & 0 deletions AspireStarterApp_WithMauiIntegration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
## Walkthrough Steps

### Preparation

1. Please follow the steps in [Install Aspire CLI](../Setup_Aspire/InstallOrUpdateAspire.md#install-aspire-cli) to install Aspire CLI.

1. Run the following command to install the MAUI workload:

`dotnet workload install maui`
3. Run the following command to Install the devtunnel CLI (The Dev Tunnels is for iOS and Android platforms)

`winget install Microsoft.devtunnel`

- Please run `devtunnel user login` before using the dev tunnel
![Aspire run](_images/AspireStarterApp_WithMauiIntegration/login_devtunnel.png)

#### If CONTEXT contains Android emulator with Dev Tunnel
1. install the VS with the .NET Multi-platform App UI development workload

1. you will need to create a virtual Android device.
- Use Tools > Android > Android Device Manager
- Click New
- Choose Base Device: Pixel 7 (+ Store)
- Choose Processor: X86_64
- Choose OS: Android with API level 36 or higher (pick the highest available API level)
- Ensure that Google APIs is checked and Google Play Store is unchecked
- Click Create
- When it has been created, close the Android Device Manager window

### Create an Aspire Empty App using CLI

1. Open a normal Command Prompt (do not run as administrator).

1. Use the following command to create an Aspire Empty App project.

```
aspire new aspire-starter --name AspireWithMaui
```

1. Enter the output path Or press 'Enter' button to use the default path. Select a template version.

![Create](_images/AspireStarterApp_WithMauiIntegration/Create_CLI.png)

### Create an .NET MAUI Blazor Hybrid App using CLI

1. Go to AspireStarterApp project:

```
cd AspireWithMaui
```
1. Create a .NET MAUI Blazor Hybrid App project

```
dotnet new maui-blazor -o AspireWithMaui.MauiClient
```

1. Add the maui project to the .sln
```
dotnet sln add AspireWithMaui.MauiClient/AspireWithMaui.MauiClient.csproj
```

1. Go to AspireStarterApp.AppHost project, and add package:

```
cd AspireWithMaui.AppHost
```
1. Go to AppHost project, add MAUI integration to the Aspire host project
```
aspire add Aspire.Hosting.Maui --version <aspire template version>
```

#### If CONTEXT contains Windows device

1. Open the AppHost.cs file of AspireWithMaui.AppHost project, add the following code:

```
// Add the .NET MAUI project resource
var mauiapp = builder.AddMauiProject("myapp", @"../AspireWithMaui.MauiClient/AspireWithMaui.MauiClient.csproj");

// Add MAUI app for Windows
mauiapp.AddWindowsDevice()
.WithReference(apiService);
```
![Aspire run](_images/AspireStarterApp_WithMauiIntegration/update_Apphost.png)

#### If CONTEXT contains Android emulator with Dev Tunnel

1. Open the AppHost.cs file of AspireWithMaui.AppHost project, add the following code:

```
// Create a public dev tunnel for iOS and Android
var publicDevTunnel = builder.AddDevTunnel("devtunnel-public")
.WithAnonymousAccess()
.WithReference(apiService.GetEndpoint("https"));

// Add the .NET MAUI project resource
var mauiapp = builder.AddMauiProject("myapp", @"../AspireWithMaui.MauiClient/AspireWithMaui.MauiClient.csproj");

// Add MAUI app for Android running on the emulator with default emulator (uses running or default emulator, needs to be started)
mauiapp.AddAndroidEmulator()
.WithOtlpDevTunnel() // Needed to get the OpenTelemetry data to "localhost"
.WithReference(apiService, publicDevTunnel); // Needs a dev tunnel to reach "localhost"
```
![Aspire run](_images/AspireStarterApp_WithMauiIntegration/update_Apphost2.png)

### Run the project

1. Run the Aspire project using the following command:

```
aspire run
```

1. After a successful run, please check the following items:

- Verify that there is no error in CMD
- Open the Dashboard link in CMD and verify that all links and functions on the page are working properly
- Verify that the Maui Blazor application can be started manually and runs normally

![Aspire run](_images/AspireStarterApp_WithMauiIntegration/Dashboard.png)

![Aspire run](_images/AspireStarterApp_WithMauiIntegration/MauiClientApp.png)

- Before running an Aspire project, you need to manually launch the Android emulator.
![Aspire run](_images/AspireStarterApp_WithMauiIntegration/Dashboard_Android.png)

1. Press Ctrl+C to stop the app host and exit.

### Publish the project

1. Run `aspire publish --non-interactive`, generates deployment artifacts for an Aspire host project.

![Aspire publish](_images/AspireStarterApp_WithMauiIntegration/publish.png)
154 changes: 154 additions & 0 deletions AspireStarterApp_WithMauiIntegration_fromMac.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
## Walkthrough Steps

### Preparation

1. Please follow the steps in [Install Aspire CLI](../Setup_Aspire/InstallOrUpdateAspire.md#install-aspire-cli) to install Aspire CLI.

1. Run the following command to install the MAUI workload:

`dotnet workload install maui`

2. Run the following command to Install the devtunnel CLI

`winget install Microsoft.devtunnel`

- Please run `devtunnel user login` before using the dev tunnel
![Aspire run](_images/AspireStarterApp_WithMauiIntegration/login_devtunnel.png)

#### If CONTEXT contains iOS simulator with Dev Tunnel

1. Install Xcode: https://apps.apple.com/us/app/xcode/id497799835?mt=12

1. Install Command Line Developer Tools and IOS simulator

#### If CONTEXT contains Android emulator with Dev Tunnel

1. Install Android Studio

- Download: https://developer.android.com/studio
1. Install Android emulator according these [steps](https://github.com/dotnet/AspNetCore-ManualTests/blob/release/10.0/AspNetCore10/BlazorHybrid/10_BlazorHybrid_Android_FromMac.md#install-the-latest-android-sdk)

### Create an Aspire Starter App using CLI

1. Open a normal Command Prompt (do not run as administrator).

1. Use the following command to create an Aspire Starter App project.

```
aspire new aspire-starter --name AspireWithMaui
```

1. Enter the output path Or press 'Enter' button to use the default path. Select a template version.

![Create](_images/AspireStarterApp_WithMauiIntegration/Create_CLI.png)

### Create an .NET MAUI Blazor Hybrid App using CLI

1. Go to AspireStarterApp project:

```
cd AspireWithMaui
```
1. Create a .NET MAUI Blazor Hybrid App project

```
dotnet new maui-blazor -o AspireWithMaui.MauiClient
```

1. Add the maui project to the .sln
```
dotnet sln add AspireWithMaui.MauiClient/AspireWithMaui.MauiClient.csproj
```

1. Go to AspireStarterApp.AppHost project, and add package:

```
cd AspireWithMaui.AppHost
```
1. Go to AppHost project, add MAUI integration to the Aspire host project
```
aspire add Aspire.Hosting.Maui --version <aspire template version>
```

#### If CONTEXT contains Mac Catalyst

1. Open the AppHost.cs file of AspireWithMaui.AppHost project, add the following code:

```
// Add the .NET MAUI project resource
var mauiapp = builder.AddMauiProject("myapp", @"../AspireWithMaui.MauiClient/AspireWithMaui.MauiClient.csproj");

// Add MAUI app for Mac Catalyst
mauiapp.AddMacCatalystDevice().WithReference(apiService);
```

#### If CONTEXT contains IOS emulator with Dev Tunnel

1. Open the AppHost.cs file of AspireWithMaui.AppHost project, add the following code:

```
// Create a public dev tunnel for iOS and Android
var publicDevTunnel = builder.AddDevTunnel("devtunnel-public")
.WithAnonymousAccess()
.WithReference(weatherApi.GetEndpoint("https"));

// Add the .NET MAUI project resource
var mauiapp = builder.AddMauiProject("myapp", @"../AspireWithMaui.MauiClient/AspireWithMaui.MauiClient.csproj");

// Add MAUI app for iOS running on the iOS Simulator (starts a random one, or uses the currently started one)
mauiapp.AddiOSSimulator()
.WithOtlpDevTunnel() // Needed to get the OpenTelemetry data to "localhost"
.WithReference(apiService, publicDevTunnel); // Needs a dev tunnel to reach "localhost"
```

#### If CONTEXT contains Android emulator with Dev Tunnel

1. Open the AppHost.cs file of AspireWithMaui.AppHost project, add the following code:

```
// Create a public dev tunnel for iOS and Android
var publicDevTunnel = builder.AddDevTunnel("devtunnel-public")
.WithAnonymousAccess()
.WithReference(weatherApi.GetEndpoint("https"));

// Add the .NET MAUI project resource
var mauiapp = builder.AddMauiProject("myapp", @"../AspireWithMaui.MauiClient/AspireWithMaui.MauiClient.csproj");

// Add Android emulator with Dev Tunnel
mauiapp.AddAndroidEmulator()
.WithOtlpDevTunnel() // Required for OpenTelemetry data collection
.WithReference(weatherApi, publicDevTunnel);
```

### Run the project

1. Run the Aspire project using the following command:

```
aspire run
```

1. After a successful run, please check the following items:

- Verify that there is no error in CMD
- Open the Dashboard link in CMD and verify that all links and functions on the page are working properly
- Verify that the Maui Blazor application can be started manually and runs normally

Mac Catalyst:
![Aspire run](_images/AspireStarterApp_WithMauiIntegration/Dashboard_MacCatalyst.png)

iOS:
![Aspire run](_images/AspireStarterApp_WithMauiIntegration/Dashboard_iOS.png)

Android:
- Before running an Aspire project, you need to manually launch the Android emulator.

![Aspire run](_images/AspireStarterApp_WithMauiIntegration/Dashboard_Android.png)

1. Press Ctrl+C to stop the app host and exit.

### Publish the project

1. Run `aspire publish --non-interactive`, generates deployment artifacts for an Aspire host project.

![Aspire publish](_images/AspireStarterApp_WithMauiIntegration/publish.png)
3 changes: 0 additions & 3 deletions README.md

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.