question

DeviPrasad-9634 avatar image
0 Votes"
DeviPrasad-9634 asked DeviPrasad-9634 published

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

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'

dotnet-maui
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

NicoZhu-MSFT avatar image
1 Vote"
NicoZhu-MSFT answered DeviPrasad-9634 published

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.



· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@NicoZhu-MSFT It's fine with any target, thank you for your info;.

1 Vote 1 ·

@NicoZhu-MSFT It is working in Any CPU mode but I wants to test the application in x86 also How can I do that please let me know.

0 Votes 0 ·

You could refer to mattleibow repliy here and use the RID and change that with a condition if need be. This means you get an Any CPU managed .dll, but the final app is building for the platform you selected in the RID. Please add the following into porject csproj file.

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





0 Votes 0 ·

@NicoZhu-MSFT If we wants to run in x64 do we need to change the file again, or there any other option in project settings we can change this ?

0 Votes 0 ·
Show more comments