Skip to content

Commit 3796564

Browse files
committed
Use bitness from process or OS (microsoft#2571)
1 parent c5becb6 commit 3796564

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/vstest.console/TestPlatformHelpers/TestRequestManager.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,19 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List<string> sou
451451
|| chosenFramework.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0
452452
|| chosenFramework.Name.IndexOf("net5", StringComparison.OrdinalIgnoreCase) >= 0)
453453
{
454-
defaultArchitecture = Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86;
454+
#if NETCOREAPP
455+
// We are running in vstest.console that is either started via dotnet.exe or via vstest.console.exe .NET Core
456+
// executable. For AnyCPU dlls this should resolve 32-bit SDK when running from 32-bit dotnet process and
457+
// 64-bit SDK when running from 64-bit dotnet process.
458+
defaultArchitecture = Environment.Is64BitProcess ? Architecture.X64 : Architecture.X86;
459+
#else
460+
// We are running in vstest.console.exe that was built against .NET Framework. This console prefers 32-bit
461+
// because it needs to run as 32-bit to be compatible with QTAgent. It runs as 32-bit both under VS and
462+
// in Developer console. Set the default architecture based on the OS architecture, to find 64-bit dotnet SDK
463+
// when running AnyCPU dll on 64-bit system, and 32-bit SDK when running AnyCPU dll on 32-bit OS.
464+
// We want to find 64-bit SDK because it is more likely to be installed.
465+
defaultArchitecture = Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86;
466+
#endif
455467
}
456468

457469
settingsUpdated |= this.UpdatePlatform(document, navigator, sources, sourcePlatforms, defaultArchitecture, out Architecture chosenPlatform);

0 commit comments

Comments
 (0)