# MauiWindowsExtensions Methods

- Package: [Aspire.Hosting.Maui](/reference/api/csharp/aspire.hosting.maui.md)
- Type: [MauiWindowsExtensions](/reference/api/csharp/aspire.hosting.maui/mauiwindowsextensions.md)
- Kind: `Methods`
- Members: `2`

Provides extension methods for adding Windows platform resources to MAUI projects.

## AddWindowsDevice(IResourceBuilder<MauiProjectResource>)

- Name: `AddWindowsDevice(IResourceBuilder<MauiProjectResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<MauiWindowsPlatformResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/becb48e2d61099e35ae336d527d3875e928d6594/src/Aspire.Hosting.Maui/MauiWindowsExtensions.cs#L45-L48)

Adds a Windows device resource to run the MAUI application on the Windows platform.

```csharp
public static class MauiWindowsExtensions
{
    public static IResourceBuilder<MauiWindowsPlatformResource> AddWindowsDevice(
        this IResourceBuilder<MauiProjectResource> builder)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<MauiProjectResource>`)
  The MAUI project resource builder.

## Returns

`IResourceBuilder<MauiWindowsPlatformResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

This method creates a new Windows platform resource that will run the MAUI application targeting the Windows platform using `dotnet run`. The resource does not auto-start and must be explicitly started from the dashboard by clicking the start button.

The resource name will default to "{projectName}-windows".

This overload is not available in polyglot app hosts. Use [MauiWindowsExtensions.AddWindowsDevice(IResourceBuilder<MauiProjectResource>)](/reference/api/csharp/aspire.hosting.maui/mauiwindowsextensions/methods.md#addwindowsdevice-iresourcebuilder-mauiprojectresource) instead.

## Examples

Add a Windows device to a MAUI project:

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var maui = builder.AddMauiProject("mauiapp", "../MyMauiApp/MyMauiApp.csproj");
var windowsDevice = maui.AddWindowsDevice();

builder.Build().Run();
```

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AddWindowsDevice(IResourceBuilder<MauiProjectResource>, string)

- Name: `AddWindowsDevice(IResourceBuilder<MauiProjectResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<MauiWindowsPlatformResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/becb48e2d61099e35ae336d527d3875e928d6594/src/Aspire.Hosting.Maui/MauiWindowsExtensions.cs#L83-L109)

Adds a Windows device resource to run the MAUI application on the Windows platform with a specific name.

```csharp
public static class MauiWindowsExtensions
{
    public static IResourceBuilder<MauiWindowsPlatformResource> AddWindowsDevice(
        this IResourceBuilder<MauiProjectResource> builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<MauiProjectResource>`)
  The MAUI project resource builder.
- `name` (`string`)
  The name of the Windows device resource.

## Returns

`IResourceBuilder<MauiWindowsPlatformResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

This method creates a new Windows platform resource that will run the MAUI application targeting the Windows platform using `dotnet run`. The resource does not auto-start and must be explicitly started from the dashboard by clicking the start button.

You can add multiple Windows device resources to a MAUI project by calling this method multiple times with different names.

## Examples

Add multiple Windows devices to a MAUI project:

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var maui = builder.AddMauiProject("mauiapp", "../MyMauiApp/MyMauiApp.csproj");
var windowsDevice1 = maui.AddWindowsDevice("windows-device-1");
var windowsDevice2 = maui.AddWindowsDevice("windows-device-2");

builder.Build().Run();
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
