dotnet / project-system

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

Project properties build page shows incorrect platform target #3088

Open vsfeedback opened 6 years ago

vsfeedback commented 6 years ago

Scenario: Create a .NET Core class library, and then change its Output Type to Windows Application. (This is useful among other reasons for running an integration test directly, because Test Explorer is so slow.)

Actual result: After you make the change, the Build page of the project properties shows Build Target as x86. However, when you run the executable, it actually runs as x64. This can cause mysterious BadImageFormatException exceptions.

Expected result: The Build page's Platform Target should show Any CPU or something to indicate that the project does not have a specified target.

This issue has been moved from https://developercommunity.visualstudio.com/content/problem/175082/project-properties-build-page-shows-incorrect-plat.html VSTS ticketId: 545711 These are the original issue comments: (no comments) These are the original issue solutions:

Edward Brey solved on 1/1/2018, 07:49 AM (26 hours ago), 0 votes:

Once you discover that the problem is, the workarounds are pretty easy. You can change the target to some other value and then change it back.

Alternatively, you can add a runtime identifier to the .csproj. If you need your .exe to run as x86 so that it can load a x86 native DLL, add this element within a PropertyGroup:

<RuntimeIdentifier>win-x86</RuntimeIdentifier>

A good place to put this is right after the TargetFramework or TargetFrameworks element.

SabotageAndi commented 6 years ago

This bug is still existing in VS 2017 15.7.1 and 15.8.0 Preview 1.1.