|
1 | 1 | --- |
2 | | -title: "NETSDK1144: Optimizing assemblies for size failed" |
3 | | -description: How to resolve the optimizing for size failed message. |
| 2 | +title: "NETSDK1032: RuntimeIdentifier and PlatformTarget must be compatible." |
| 3 | +description: How to resolve the NETSDK1032 error 'RuntimeIdentifier and PlatformTarget must be compatible.' |
4 | 4 | author: tdykstra |
5 | 5 | ms.topic: error-reference |
6 | 6 | ms.date: 01/14/2025 |
| 7 | +ai-usage: ai-assisted |
7 | 8 | f1_keywords: |
8 | | -- NETSDK1144 |
| 9 | +- NETSDK1032 |
9 | 10 | --- |
10 | | -# NETSDK1144: Duplicate items were included |
| 11 | +# NETSDK1032: RuntimeIdentifier and PlatformTarget must be compatible |
11 | 12 |
|
12 | | -**This article applies to:** ✔️ .NET Core 2.1.100 SDK and later versions |
| 13 | +The error `NETSDK1032` occurs when there is a mismatch between the `RuntimeIdentifier` (RID), such as `win-x64` or `linux-x64`, and the `PlatformTarget`, such as `x64` or `x86`. The full error message is similar to the following example: |
13 | 14 |
|
14 | | -## Causes of .NET Build Error Code NETSDK1144 |
| 15 | +> The `RuntimeIdentifier` platform '{RID}' and the `PlatformTarget` '{Target}' must be compatible. |
15 | 16 |
|
16 | | -One cause of error code `NETSDK1144` is a `UseAppHost` property set to `true` in a project that targets a runtime identifier (RID) that does not support an application host. This typically happens when building a project for a platform that doesn't support generating an executable host. |
| 17 | +The RID is specified in the project file or passed into the build process from the command line. If not specified, the default RID used is `win-x64` for Windows, `linux-x64` for Linux, and `osx-x64` for macOS. |
17 | 18 |
|
18 | | -## How to Fix NETSDK1144 Errors |
| 19 | +The `PlatformTarget` is specified in the project file or passed into the build process from the command line. If not specified, the default is `AnyCPU`. With `PlatformTarget` set to `AnyCPU`, the application can run on both 32-bit and 64-bit platforms. The runtime executes the app as 64-bit if the OS is 64-bit, and as 32-bit for a 32-bit OSif the OS is 32-bit. |
19 | 20 |
|
20 | | -1. Check the Target Runtime Identifier (RID): |
21 | | - - Ensure that the RID specified in your project file is correct and supported for generating an application host. |
22 | | - - Some common RIDs are `win-x64`, `linux-x64`, `osx-x64`. |
| 21 | +Here's an example of a `.csproj` file with incompatible RID and `PlatformTarget` settings (x86 and x64): |
23 | 22 |
|
24 | | -2. Modify the `UseAppHost` Property or remove unsupported RIDs: |
25 | | - - If the target RID does not support an application host, set the `UseAppHost` property to `false` in your project file. |
26 | | - - If you're targeting multiple RIDs, remove any that don't support generating an application host. |
| 23 | +```xml |
| 24 | +<Project Sdk="Microsoft.NET.Sdk"> |
27 | 25 |
|
28 | | -## Example Fix |
| 26 | + <PropertyGroup> |
| 27 | + <OutputType>Exe</OutputType> |
| 28 | + <TargetFramework>net8.0</TargetFramework> |
| 29 | + <PlatformTarget>x86</PlatformTarget> |
| 30 | + <RuntimeIdentifier>win-x64</RuntimeIdentifier> |
| 31 | + </PropertyGroup> |
29 | 32 |
|
30 | | -Here is an example of a `.csproj` file with the `UseAppHost` property set to `false`: |
| 33 | +</Project> |
| 34 | +``` |
| 35 | + |
| 36 | +Fix this error by changing either `PlatformTarget` or `RuntimeIdentifier`. For example: |
31 | 37 |
|
32 | 38 | ```xml |
33 | 39 | <Project Sdk="Microsoft.NET.Sdk"> |
34 | 40 |
|
35 | 41 | <PropertyGroup> |
36 | 42 | <OutputType>Exe</OutputType> |
37 | | - <TargetFramework>net6.0</TargetFramework> |
38 | | - <RuntimeIdentifier>linux-arm</RuntimeIdentifier> |
39 | | - <UseAppHost>false</UseAppHost> |
| 43 | + <TargetFramework>net8.0</TargetFramework> |
| 44 | + <!-- Change the PlatformTarget to match the RID. --> |
| 45 | + <PlatformTarget>x64</PlatformTarget> |
| 46 | + <RuntimeIdentifier>win-x64</RuntimeIdentifier> |
40 | 47 | </PropertyGroup> |
41 | 48 |
|
42 | 49 | </Project> |
43 | 50 | ``` |
44 | 51 |
|
45 | | -In this example, the `UseAppHost` property is set to `false` because the `linux-arm` RID does not support generating an application host. |
| 52 | +Or: |
| 53 | + |
| 54 | +```xml |
| 55 | +<Project Sdk="Microsoft.NET.Sdk"> |
| 56 | + |
| 57 | + <PropertyGroup> |
| 58 | + <OutputType>Exe</OutputType> |
| 59 | + <TargetFramework>net8.0</TargetFramework> |
| 60 | + <PlatformTarget>x86</PlatformTarget> |
| 61 | + <!-- Change the RID to match the PlatformTarget. --> |
| 62 | + <RuntimeIdentifier>win-x86</RuntimeIdentifier> |
| 63 | + </PropertyGroup> |
| 64 | + |
| 65 | +</Project> |
| 66 | +``` |
0 commit comments