dotnet / project-system

The .NET Project System for Visual Studio
MIT License
968 stars 387 forks source link

Problem when PlatformTarget is omitted from .csproj #5901

Open vsfeedback opened 4 years ago

vsfeedback commented 4 years ago

This issue has a corresponding ticket on Developer Community. Please vote and comment there to make sure your voice is heard.


This is a problem when using .NET Framework with .csproj in SDK-style.

If you omit <PlatformTarget>, the target platform will be displayed as "x86" in the GUI project settings, but it will be executed in 64bit.

I think "AnyCPU" is the correct.

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net472</TargetFramework>
  </PropertyGroup>

</Project>
davkean commented 4 years ago

Removing Triage markings, this wasn't assigned to anyone.

drewnoakes commented 2 years ago

The above project shows this in the new Project Properties UI:

image

Looking at a design-time build, I see that PlatformTarget is evaluated as x86 and changed to AnyCPU in target AdjustDefaultPlatformTargetForNetFrameworkExeWithNoNativeCopyLocalItems.

https://github.com/dotnet/sdk/blob/6c5d3376a4f581090be1f8cd453907166209fe4f/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets#L241-L257

It seems we're currently getting this value from evaluation, but need it from build.