question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tests always run x64 in VS (even when selecting x86)

See original GitHub issue

Problem

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.Sdk to 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.csproj and 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.exe of whatever build-local.ps1 installs
  • observe that you can now run both PRINTDLGW_32_ensure_layout and PRINTDLGW_64_ensure_layout from PR #2851 inside VS (you can switch the bitness of the test runner in the test explorer toolbar)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
RussKiecommented, Sep 9, 2020

@weltkante do you think we can close this? I think we resolved this issue.

1reaction
weltkantecommented, Jun 4, 2020

Invoking commands with -platform x86 don’t work

It works enough to get the x86 runtime installed, which is all I wanted 😄

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found