Home > OS >  Configure VS to only build for a specific Target for multiple Targets project (MAUI)?
Configure VS to only build for a specific Target for multiple Targets project (MAUI)?

Time:11-28

I have a habit of pressing Ctrl Shift B during development to make sure my changes are valid. However, for a MAUI project, pressing that combination results in multiple platforms being built like this:

enter image description here

It takes a very long time for it to finish, and cancelling the Build makes Intellisense going nuts everywhere.

I know that when I press F5 or Ctrl F5, the build is very quickly because only the platform I am running it on is being compiled. Is there anyway to temporarily disable building the binary for other platforms? I still need to support them later.

CodePudding user response:

Adjust the <TargetFrameworks> entries in your csproj file. This is the default given by one of the project templates:

<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->

This will compile for

  • Android
  • IOS
  • MacOS
  • Windows (but only if you're compiling from a Windows computer)
  • NOT Tizen

Just comment out what you don't want to do at the moment.

  • Related