Can i target only one platform in .NET MAUI Hybrid.?

Jignesh Desai 126 Reputation points
2025-01-24T16:42:42.36+00:00

Hi

Can i target only one platform in .NET MAUI Blazor Hybrid.?

I know that MAUI is for multiple platforms, but at the moment I am not focusing on android or others, only Windows, to publish in Microsoft Store. All i want is to take advantage of Blazor style of coding.

I tried to modify

But then I found that "Publish" option disappears.

Any guidance. ?

Developer technologies | .NET | Blazor
Developer technologies | .NET | .NET MAUI
Community Center | Not monitored
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 60,876 Reputation points
    2025-01-24T17:25:30.0566667+00:00

    Sure you can target whatever platforms are supported by MAUI. Note that by default the project file breaks up Windows from everything else.

    <TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
    

    What this says is build for Android, iOS and MacCataylst. If running on a Windows machine then also include Windows. If you want to disable non-Windows for now then comment out the first TargetFrameworks values. Then it'll just target Windows, assuming you're building on Windows.

    <!--<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>-->
    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
    

    Once you save your changes you'll need to reload the project because VS doesn't like it when you make a change like this. Once reloaded you can build and the option to publish should still be available on the context menu.

    enter image description here


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.