Partager via


NETSDK1032 : RuntimeIdentifier et PlatformTarget doivent être compatibles

L’erreur NETSDK1032 se produit lorsqu’il existe une incompatibilité entre le RuntimeIdentifier (RID), tel que win-x64 ou linux-x64, et le PlatformTarget, tel que x64 ou x86. Le message d’erreur complet est similaire à l’exemple suivant :

La plateforme RuntimeIdentifier « {RID} » et la PlatformTarget « {Target} » doivent être compatibles.

Le RID est spécifié dans le fichier projet ou la ligne de commande. S’il n’est pas spécifié, le RID par défaut utilisé est win-x64 pour Windows, linux-x64 pour Linux et osx-x64 pour macOS.

La PlatformTarget est spécifiée dans le fichier projet ou la ligne de commande. S’il n’est pas spécifié, la valeur par défaut est AnyCPU.

Voici un exemple de fichier .csproj avec des paramètres RID incompatibles et PlatformTarget :

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <PlatformTarget>x86</PlatformTarget>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
  </PropertyGroup>
</Project>

Corrigez le fichier .csproj précédent en modifiant PlatformTarget ou RuntimeIdentifier. Par exemple, modifiez PlatformTarget pour qu’elle corresponde au RID :

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <PlatformTarget>x64</PlatformTarget>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
  </PropertyGroup>
</Project>

Ou modifiez le RID pour qu’il corresponde à le PlatformTarget:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <PlatformTarget>x86</PlatformTarget>
    <RuntimeIdentifier>win-x86</RuntimeIdentifier>
  </PropertyGroup>
</Project>