Skip to content

Document NETSDK1032 and NETSDK1144 #44452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions docs/core/tools/sdk-errors/index.md
Original file line number Diff line number Diff line change
@@ -29,7 +29,6 @@ f1_keywords:
- NETSDK1029
- NETSDK1030
- NETSDK1031
- NETSDK1032
- NETSDK1042
- NETSDK1043
- NETSDK1044
@@ -110,7 +109,6 @@ f1_keywords:
- NETSDK1140
- NETSDK1142
- NETSDK1143
- NETSDK1144
- NETSDK1146
- NETSDK1148
- NETSDK1150
@@ -208,7 +206,7 @@ This list is a complete list of the errors that you might get from the .NET SDK
|NETSDK1029|Unable to use '{0}' as application host executable as it does not contain the expected placeholder byte sequence '{1}' that would mark where the application name would be written.|
|NETSDK1030|Given file name '{0}' is longer than 1024 bytes.|
|NETSDK1031|It is not supported to build or publish a self-contained application without specifying a RuntimeIdentifier. You must either specify a RuntimeIdentifier or set SelfContained to false.|
|NETSDK1032|The RuntimeIdentifier platform '{0}' and the PlatformTarget '{1}' must be compatible.|
|[NETSDK1032](netsdk1032.md)|The RuntimeIdentifier platform '{0}' and the PlatformTarget '{1}' must be compatible.|
|NETSDK1042|Could not load PlatformManifest from '{0}' because it did not exist.|
|NETSDK1043|Error parsing PlatformManifest from '{0}' line {1}. Lines must have the format {2}.|
|NETSDK1044|Error parsing PlatformManifest from '{0}' line {1}. {2} '{3}' was invalid.|
@@ -307,7 +305,7 @@ This list is a complete list of the errors that you might get from the .NET SDK
|[NETSDK1141](netsdk1141.md)|Unable to resolve the .NET SDK version as specified in the global.json located at {0}.|
|NETSDK1142|Including symbols in a single file bundle is not supported when publishing for .NET5 or higher.|
|NETSDK1143|Including all content in a single file bundle also includes native libraries. If IncludeAllContentForSelfExtract is true, IncludeNativeLibrariesForSelfExtract must not be false.|
|NETSDK1144|Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false.|
|[NETSDK1144](netsdk1144.md)|Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false.|
|[NETSDK1145](netsdk1145.md)|The {0} pack is not installed and NuGet package restore is not supported. Upgrade Visual Studio, remove global.json if it specifies a certain SDK version, and uninstall the newer SDK. For more options visit <https://aka.ms/targeting-apphost-pack-missing>. Pack Type:{0}, Pack directory: {1}, targetframework: {2}, Pack PackageId: {3}, Pack Package Version: {4}.|
|NETSDK1146|PackAsTool does not support TargetPlatformIdentifier being set. For example, TargetFramework cannot be net5.0-windows, only net5.0. PackAsTool also does not support UseWPF or UseWindowsForms when targeting .NET 5 and higher.|
|[NETSDK1147](netsdk1147.md)|To build this project, the following workloads must be installed: {0}.|
58 changes: 58 additions & 0 deletions docs/core/tools/sdk-errors/netsdk1032.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: "NETSDK1032: RuntimeIdentifier and PlatformTarget must be compatible."
description: How to resolve the NETSDK1032 error 'RuntimeIdentifier and PlatformTarget must be compatible.'
author: tdykstra
ms.topic: error-reference
ms.date: 01/14/2025
ai-usage: ai-assisted
f1_keywords:
- NETSDK1032
---
# NETSDK1032: RuntimeIdentifier and PlatformTarget must be compatible

The error `NETSDK1032` occurs when there's 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:

> The `RuntimeIdentifier` platform '{RID}' and the `PlatformTarget` '{Target}' must be compatible.

The RID is specified in the project file or the command line. If not specified, the default RID used is `win-x64` for Windows, `linux-x64` for Linux, and `osx-x64` for macOS.

The `PlatformTarget` is specified in the project file or the command line. If not specified, the default is `AnyCPU`.

Here's an example of a `.csproj` file with incompatible RID and `PlatformTarget` settings:

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

Fix the preceding `.csproj` file by changing either `PlatformTarget` or `RuntimeIdentifier`. For example, change `PlatformTarget` to match the RID:

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

Or change the RID to match the `PlatformTarget`:

```xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
</PropertyGroup>
</Project>
```
42 changes: 42 additions & 0 deletions docs/core/tools/sdk-errors/netsdk1144.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: "NETSDK1144: Optimizing assemblies for size failed"
description: How to resolve the 'optimizing for size failed' message.
author: tdykstra
ms.topic: error-reference
ms.date: 01/14/2025
ai-usage: ai-assisted
f1_keywords:
- NETSDK1144
---
# NETSDK1144: Optimizing assemblies for size failed

## Error Message

The error `NETSDK1144` is reported when an error occurs in the trimming process. The full error message is similar to the following example:

> Optimizing assemblies for size failed. Optimization can be disabled by setting the `PublishTrimmed` property to false.

To disable trimming, set the `PublishTrimmed` property to `false` in the project file or the command line:

```xml
<PropertyGroup>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
```

```dotnetcli
dotnet publish /p:PublishTrimmed=false
```

Here's an example of a `.csproj` file with trimming disabled:

```xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>linux-arm</RuntimeIdentifier>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
</Project>
```
4 changes: 4 additions & 0 deletions docs/navigate/tools-diagnostics/toc.yml
Original file line number Diff line number Diff line change
@@ -33,6 +33,8 @@ items:
href: ../../core/tools/sdk-errors/netsdk1013.md
- name: NETSDK1022
href: ../../core/tools/sdk-errors/netsdk1022.md
- name: NETSDK1032
href: ../../core/tools/sdk-errors/netsdk1032.md
- name: NETSDK1045
href: ../../core/tools/sdk-errors/netsdk1045.md
- name: NETSDK1059
@@ -67,6 +69,8 @@ items:
href: ../../core/tools/sdk-errors/netsdk1138.md
- name: NETSDK1141
href: ../../core/tools/sdk-errors/netsdk1141.md
- name: NETSDK1144
href: ../../core/tools/sdk-errors/netsdk1144.md
- name: NETSDK1145
href: ../../core/tools/sdk-errors/netsdk1145.md
- name: NETSDK1147