dotnet / dotnet/sdk

Flag usage of non-AnyCPU values for PlatformTarget in modern .NET applications

Open
#42,556 3 comments 1 reaction 1 assignee Assigned to @Copilot View on GitHub
Area-NetSDK msbuild-analyzer-candidate
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Is your feature request related to a problem? Please describe.

The `PlatformTarget` field (and therefore Platform in MSbuild) only applies to .NET Framework and doesn't apply to modern .NET applications. For these applications, Platform can (should) always be `AnyCPU`. We should guide users to removing customizations to this property for projects that do not need it.

From Jan Kotas in dotnet/sdk#42344:

> PlatformTarget is left-over from .NET Framework. (PlatformTarget can only represent architectures that .NET Framework targets. It does not represent full range of platforms that .NET Core can target.)
>
> If you are targeting current .NET, building everything as AnyCPU (ie hardcoding PlatformTarget to AnyCPU) all the time should work just fine. It is what we are doing in dotnet/runtime repo. We hardcode PlatformTarget to AnyCPU, even for platform-specific binaries.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.