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
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="10.0.0-rc.1.25452.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.0-rc.2.25465.106" />
<PackageReference Include="System.Net.Http.Json" Version="10.0.0-rc.2.25465.106" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.0-rc.2.25465.106" />
<PackageReference Include="Microsoft.Maui.Controls" Version="10.0.20" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.2" />
<PackageReference Include="System.Net.Http.Json" Version="10.0.2" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public static MauiApp CreateMauiApp()
builder.Services.AddHttpClient<IWeatherService, WeatherService>(client =>
{
// This will be resolved via service discovery when running with Aspire
client.BaseAddress = new Uri("https://webapi");
// Use https+http:// scheme to allow fallback to HTTP when HTTPS is not available
// (e.g., when running on Android emulator without dev tunnels)
client.BaseAddress = new Uri("https+http://webapi");
});

#if DEBUG
Expand Down
32 changes: 32 additions & 0 deletions src/Aspire.Hosting.Maui/Annotations/MauiBuildInfoAnnotation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Aspire.Hosting.ApplicationModel;

namespace Aspire.Hosting.Maui.Annotations;

/// <summary>
/// Annotation carrying the build parameters for a MAUI platform resource, used by
/// <see cref="Aspire.Hosting.Maui.Lifecycle.MauiBuildQueueEventSubscriber"/> to run the Build target
/// before DCP launches the Run target.
/// </summary>
internal sealed class MauiBuildInfoAnnotation(
string projectPath,
string workingDirectory,
string? targetFramework) : IResourceAnnotation
{
/// <summary>
/// Gets the absolute path to the project file.
/// </summary>
public string ProjectPath { get; } = projectPath;

/// <summary>
/// Gets the working directory for the build process.
/// </summary>
public string WorkingDirectory { get; } = workingDirectory;

/// <summary>
/// Gets the target framework moniker (e.g., net10.0-android).
/// </summary>
public string? TargetFramework { get; } = targetFramework;
}
50 changes: 50 additions & 0 deletions src/Aspire.Hosting.Maui/Annotations/MauiBuildQueueAnnotation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Concurrent;
using Aspire.Hosting.ApplicationModel;

namespace Aspire.Hosting.Maui.Annotations;

/// <summary>
/// Annotation added to <see cref="MauiProjectResource"/> to serialize builds across
/// platform resources that share the same project.
/// </summary>
internal sealed class MauiBuildQueueAnnotation : IResourceAnnotation
{
/// <summary>
/// Gets the semaphore used to serialize builds for this project.
/// </summary>
public SemaphoreSlim BuildSemaphore { get; } = new(1, 1);

/// <summary>
/// Per-resource CTS that allows the stop command to cancel a queued or building resource.
/// The key is the resource name.
/// </summary>
public ConcurrentDictionary<string, CancellationTokenSource> ResourceCancellations { get; } = new();

/// <summary>
/// Cancels a resource's queued or building state.
/// </summary>
/// <returns><c>true</c> if the resource was found and cancelled; <c>false</c> otherwise.</returns>
public bool CancelResource(string resourceName)
{
if (ResourceCancellations.TryRemove(resourceName, out var cts))
{
try
{
cts.Cancel();
}
catch (ObjectDisposedException)
{
// The CTS was disposed by the event handler's using block after the build
// completed naturally at the exact moment the user clicked stop.
return false;
}

return true;
}

return false;
}
}
1 change: 1 addition & 0 deletions src/Aspire.Hosting.Maui/Aspire.Hosting.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
<PackageTags>aspire maui hosting</PackageTags>
<PackageIconFullPath>$(SharedDir)Maui_265x.png</PackageIconFullPath>
<NoWarn>$(NoWarn);ASPIREMAUI001</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading
Loading