Partilhar via


NETSDK1032: RuntimeIdentifier e PlatformTarget devem ser compatíveis

O erro NETSDK1032 ocorre quando há uma incompatibilidade entre o RuntimeIdentifier (RID), como win-x64 ou linux-x64, e o PlatformTarget, como x64 ou x86. A mensagem de erro completa é semelhante ao exemplo a seguir:

A plataforma RuntimeIdentifier '{RID}' e a PlatformTarget '{Target}' devem ser compatíveis.

O RID é especificado no arquivo de projeto ou na linha de comando. Se não for especificado, o RID padrão usado é win-x64 para Windows, linux-x64 para Linux e osx-x64 para macOS.

O PlatformTarget é especificado no arquivo de projeto ou na linha de comando. Se não for especificado, o padrão será AnyCPU.

Aqui está um exemplo de um arquivo .csproj com configurações de RID e PlatformTarget incompatíveis:

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

Corrija o arquivo .csproj anterior alterando PlatformTarget ou RuntimeIdentifier. Por exemplo, altere PlatformTarget para corresponder ao RID:

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

Ou altere o RID para corresponder ao PlatformTarget:

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