The RuntimeIdentifier platform 'win10-x64' and the PlatformTarget 'x86' must be compatible Error in MAUI

Devi Prasad 91 Reputation points
2022-05-23T04:52:14.557+00:00

When I run the MAUI UWP application I am getting below error

"The RuntimeIdentifier platform 'win10-x64' and the PlatformTarget 'x86' must be compatible"

I am setting configuration to x86 and I am using Visual Studio Pro 2022(64-bit)-Preview 17.3.0

Where I need to set RuntimeIdentifier platform 'win10-x64'

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,868 questions
0 comments No comments
{count} votes

Accepted answer
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,851 Reputation points
    2022-05-23T06:47:08.703+00:00

    Hello,
    Welcome to Microsoft Q&A!

    Where I need to set RuntimeIdentifier platform 'win10-x64'

    The problem should be that you select x86 platform target to replace default Any Cpu. And this will cause RuntimeIdentifier x64 mismatch. The following is NETSdkError condition, you could navigate there by double clicking on the error message.

     <NETSdkError Condition="'$(PlatformTarget)' != 'AnyCPU' and !$(RuntimeIdentifier.ToUpperInvariant().Contains($(PlatformTarget.ToUpperInvariant())))"  
                 ResourceName="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget"  
                 FormatArguments="$(RuntimeIdentifier);$(PlatformTarget)" />  
    

    Please roll it back to AnyCPU by selecting from solution platforms list.

    Update

    You could add a extra PlatformTarget condition, when you set PlatformTarget as x64 it will jump into the first logic, otherwise jump into sceond one.

     <PropertyGroup Condition="$(TargetFramework.Contains('-windows')) and '$(Configuration)' == 'Debug' and $(PlatformTarget)=='x64'">  
       <Platforms>x64</Platforms>  
       <RuntimeIdentifier>win10-x64</RuntimeIdentifier>  
     </PropertyGroup>  
          
       <PropertyGroup Condition="$(TargetFramework.Contains('-windows')) and '$(Configuration)' == 'Debug' and $(PlatformTarget)=='x86'">  
       <Platforms>x86</Platforms>  
       <RuntimeIdentifier>win10-x86</RuntimeIdentifier>  
     </PropertyGroup>  
    

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful