sdk: Build does not honor the runtime setting

Steps to reproduce

On X64 machine run:

dotnet build -c release -r win7-x86

Expected behavior

It should generate x86 assemblies

Actual behavior

Generates x64 instead

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information: Version: 1.0.0-preview1-002702 Commit Sha: 6cde21225e

Runtime Environment: OS Name: Windows OS Version: 10.0.14352 OS Platform: Windows RID: win10-x64

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

We need to provide better UX around this in the CLI.

  1. If a project is Portable and will run against the active CLI then --runtime should not be permitted.
  2. If a project is Portable with RID-specific assets and those assets are not available for the current RID then we should fail gracefully
  3. If a project is Standalone and not targetting the current RID then we should fail gracefully

Ideally, we would also provide useful guidance e.g. The CLI on your path is a 32-bit CLI and you're trying to run a 64-bit application. Do {instructions} to run this application.

The interactions here are certainly confusing and we need to do more to communicate what is going on.

@piotrpMSFT It’s just like the linked issue. If I work in a machine with Windows 10 x64, the MSI for .NET Core SDK install the 64-bit tools and there’s no way to build the project into 32-bit. This happens at least when I create a ASP.NET Core project using the .NET Framework only and not .NET Core (I’m using a library not available for .NET Core, that’s why).

I tried adding the “win7-x86” runtime but it doesn’t work. It even creates the corresponding folder and put the binaries there put it’s all 64-bit. I also tried setting the architecture on Visual Studio but still builds 64-bit. When I copy the binaries to a x86 VM I get the error about program not compatible with the processor architecture.

I created a virtual machine running Windows 10 x86 and all development tools and the opposite happens there: The project builds only on 32-bit mode no matter what I do.