Skip to content

Set PlatformTarget to AnyCPU for modern .NET #48599

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

am11
Copy link
Member

@am11 am11 commented Apr 21, 2025

Fixes #42558.

cc @jkotas, @baronfel

@ghost ghost added Area-Infrastructure untriaged Request triage from a team member labels Apr 21, 2025
@baronfel
Copy link
Member

Thanks for starting this! It looks like the tests got removed in one of the more recent commits, though?

am11 and others added 3 commits April 21, 2025 18:28
…imeIdentifierInference.targets

Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Comment on lines +128 to +129
Modern .NET assemblies don't rely on the platform bit in the binary; they're CPU-agnostic,
and the JIT determines the actual architecture behavior at runtime.
Copy link
Member

@jkotas jkotas Apr 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Modern .NET assemblies don't rely on the platform bit in the binary; they're CPU-agnostic,
and the JIT determines the actual architecture behavior at runtime.
Outside .NET Framework, PlatformTarget does not have a real purpose since the process architecture is
determined by the host used to launch the application. Defaulting to AnyCPU naturally works on all platforms
where modern .NET is supported and makes it unnecessary to recognize these platforms as PlatformTargets.

JIT does not determine the actual architecture. The actual architecture is determined by the host.

Copy link
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you verify the impact of this on VSTest?

For modern .NET, we determine which testhost will be copied to output directory based on that.

https://github.com/microsoft/vstest/blob/main/src/package/Microsoft.TestPlatform.TestHost/Microsoft.TestPlatform.TestHost.props

I think the usage in VSTest is bad, but we need to understand how we will approach handling this breaking change.

It's also passed to VSTestTask here:
https://github.com/microsoft/vstest/blob/dbcd471883202088496ab81d3ec2d3f3be0981b5/src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.targets#L53

But for the specific usage in this task, I don't know if it's .NET Framework only or if it also affects .NET Core. @nohwnd will be the best contact here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop inferring the PlatformTarget in the SDK when targeting modern .NET applications
4 participants