Tests always run x64 in VS (even when selecting x86)
See original GitHub issueProblem
PR #2851 will introduce tests specific to x86/x64 environments but winforms build infrastructure is broken and always runs tests in x64 when running within Visual Studio, even when explicitly selecting x86 in the VS test explorer toolbar.
Workaround
run tests from console via .\build.cmd -platform x86 -test
Root Cause / Fix
- this was a bug in VS which has been fixed in 16.4
- you need to update the nuget package
Microsoft.Net.Test.Sdkto version 16.4 or newer- currently this package is pulled in by the SDK in version 16.1.1, so you either need to update the SDK or override the nuget package import
- even when importing the package with the fix you’ll still run into an error because winforms only installs the x64 sdk when running the build scripts; you also need to install the x86 sdk or VS complains
- according to this log it looks like aspnetcore already is able to install both sdks, so you should be able to do something similar
Proof of Concept
- edit
System.Windows.Forms.Primitives.Tests.csprojand add an explicit package reference<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4" /> - download and install the x86 sdk manually [edit] got the link wrong here and don’t remember the right version to download, just download the link variation ending in
x86.exeof whatever build-local.ps1 installs - observe that you can now run both
PRINTDLGW_32_ensure_layoutandPRINTDLGW_64_ensure_layoutfrom PR #2851 inside VS (you can switch the bitness of the test runner in the test explorer toolbar)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Application runs as x86 in unit tests in Visual Studio, but ...
1 Answer 1 · VS 2013: Tests->Tests Settings -> Default Processor Architecture -> x64 should select x64 for default VS test runner. ·...
Read more >vs2017 x64 unit test DO NOT WORK
Ideally VS should pick up that this is x64 assembly however as a workaround you can go to Test -> Test Settings ->...
Read more >Run a unit test as a 64-bit process - Visual Studio (Windows)
From the Visual Studio menu, choose Test, then choose Processor Architecture for AnyCPU projects. Choose x64 to run the tests as a 64-bit...
Read more >Back to Basics: 32-bit and 64-bit confusion around x86 and ...
The first question developer ask me when I'm pushing 64-bit is "Can I still run Visual Studio the same? Can I make apps...
Read more >Do we need to test 32-bit software in 64-bit Windows?
As a compromise, you could run tests on 64 bit Windows only whenever a new driver version is available. Actually, this depends on...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@weltkante do you think we can close this? I think we resolved this issue.
It works enough to get the x86 runtime installed, which is all I wanted 😄