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

Jignesh Desai 106 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. ?

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,654 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,864 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
41,663 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 56,446 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

    0 comments No comments

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.