Skip to content

Provide a way to explicitly specify a target architecture from the command line. #2576

@tannergooding

Description

@tannergooding

Issue

#2571 updated the logic so that the bitness of the host is used by default in .NET Core. This means that if you run tests from a 32-bit SDK, you will run the tests in 32-bit mode. Likewise, if you run tests from a 64-bit SDK, you will run the tests in 64-bit mode.

This works well if you only have the 32-bit or 64-bit SDK installed, such as if you are using the dotnet-install script in order to validate your code in a CI environment.

However, there may be scenarios where you are running from a particular SDK and you want to run the tests under a different architecture. For example, you may have both the 32-bit and 64-bit SDK installed. In this case, having a command line switch to specify the architecture under which tests should run would be beneficial.

Proposal

Expose a command line switch such as dotnet test --architecture x86.

This provides an escape hatch if the default logic doesn't work as the consumer requires. I would imagine it should support x86, x64, arm, and arm64 as valid and be expanded as needed in the future. This should likely also be tested under Windows on Windows, where you might be running on x64 and have x86 as a valid target or where you might be running on ARM64 and have both ARM and x86 as valid targets.

Other Considerations

It would likely be worthwhile to also document the behavior of this flag when used with a solution. A solution might have a mix of projects, some could be AnyCPU and some could target an explicit architecture. I imagine the most seamless behavior would be to automatically run non-AnyCPU binaries against their target architecture (rather than the specified target architecture), however, one could also imagine skipping or allowing explicit skipping of certain projects as you might be running on x64 but have a single project that targets arm and not have an arm SDK installed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions