Skip to content

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

@weltkante

Description

@weltkante

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 fix: PrintDialog not shown #2851 inside VS (you can switch the bitness of the test runner in the test explorer toolbar)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions