Skip to content

.NET Core can't build AnyCPU exes #1906

@davidmatson

Description

@davidmatson

(I may be misunderstanding how things are supposed to work here; apologies if this is more of a question than a bug.)

Consider the following project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net47</TargetFramework>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <RuntimeIdentifier>win</RuntimeIdentifier>
  </PropertyGroup>

</Project>

This project builds/runs correctly and generates an AnyCPU exe. Now change the target framework to .NET Core:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <RuntimeIdentifier>win</RuntimeIdentifier>
  </PropertyGroup>

</Project>

This project generates a build error:
Project is targeting runtime 'win' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core.

If RuntimeIdentifier is win-x86 or win-x64, it builds, but at publish time I suspect (though couldn't confirm) that the assemblies it generates are not AnyCPU, even though the Platform in the project file was explicitly AnyCPU.

I believe .NET Core still supports AnyCPU for DLLs. But does it really support AnyCPU for EXEs? It looks like today there isn't a clear answer - you can say you're building an AnyCPU exe, but you don't actually get an exe unless you do publish on a Self-Contained Deployment by using a RuntimeIdentifier, and no AnyCPU RuntimeIdentifier (aka just "win"?) is currently supported.

How should this work? Should .NET Core allow creating AnyCPU EXEs? If not, should the build generate an error when OutputType=Exe and Platform=AnyCPU?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions