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.
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.
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
:A good place to put this is right after the
TargetFramework
orTargetFrameworks
element.