NETSDK1032: RuntimeIdentifier e PlatformTarget devono essere compatibili
L'errore NETSDK1032
si verifica quando si verifica una mancata corrispondenza tra il RuntimeIdentifier
(RID), ad esempio win-x64
o linux-x64
, e il PlatformTarget
, ad esempio x64
o x86
. Il messaggio di errore completo è simile all'esempio seguente:
La piattaforma
RuntimeIdentifier
'{RID}' e laPlatformTarget
'{Target}' devono essere compatibili.
Il RID viene specificato nel file di progetto o nella riga di comando. Se non specificato, il RID predefinito usato è win-x64
per Windows, linux-x64
per Linux e osx-x64
per macOS.
Il PlatformTarget
viene specificato nel file di progetto o nella riga di comando. Se non specificato, il valore predefinito è AnyCPU
.
Di seguito è riportato un esempio di file .csproj
con impostazioni RID e PlatformTarget
incompatibili:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
</Project>
Correggere il file di .csproj
precedente modificando PlatformTarget
o RuntimeIdentifier
. Ad esempio, modificare PlatformTarget
in modo che corrisponda al RID:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
</Project>
In alternativa, modificare il RID in modo che corrisponda al PlatformTarget
:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
</PropertyGroup>
</Project>