From 7d461295be81153ca5ef31e5300b6b36b0ce3cde Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Thu, 29 Nov 2018 21:07:50 -0800 Subject: [PATCH] Check bitness of dotnet under test instead of test host process --- test/EndToEnd/ProjectBuildTests.cs | 3 ++- .../RepoDirectoriesProvider.cs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/test/EndToEnd/ProjectBuildTests.cs b/test/EndToEnd/ProjectBuildTests.cs index c0e81a7ab..d7ee2553e 100644 --- a/test/EndToEnd/ProjectBuildTests.cs +++ b/test/EndToEnd/ProjectBuildTests.cs @@ -41,7 +41,8 @@ namespace EndToEnd.Tests var dotnetRoot = Path.GetDirectoryName(RepoDirectoriesProvider.DotnetUnderTest); if (!string.IsNullOrEmpty(dotnetRoot)) { - runCommand = runCommand.WithEnvironmentVariable(Environment.Is64BitProcess ? "DOTNET_ROOT" : "DOTNET_ROOT(x86)", + bool useX86 = RepoDirectoriesProvider.DotnetRidUnderTest.EndsWith("x86", StringComparison.InvariantCultureIgnoreCase); + runCommand = runCommand.WithEnvironmentVariable(useX86 ? "DOTNET_ROOT(x86)" : "DOTNET_ROOT", dotnetRoot); } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs index 0200bd607..8eb8ba0d4 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Xml.Linq; +using FluentAssertions; using Microsoft.DotNet.PlatformAbstractions; namespace Microsoft.DotNet.Tools.Test.Utilities @@ -16,6 +17,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public readonly static string TestWorkingFolder; public readonly static string DotnetUnderTest; + public readonly static string DotnetRidUnderTest; static RepoDirectoriesProvider() { @@ -58,6 +60,16 @@ namespace Microsoft.DotNet.Tools.Test.Utilities DotnetUnderTest = Path.Combine(RepoRoot, "artifacts", "bin", "redist", configuration, "dotnet", "dotnet" + dotnetExtension); } } + + // TODO: Resolve dotnet folder even if DotnetUnderTest doesn't have full path + var sdkFolders = Directory.GetDirectories(Path.Combine(Path.GetDirectoryName(DotnetUnderTest), "sdk")); + sdkFolders.Length.Should().Be(1, "Only one SDK folder is expected in the layout"); + + var sdkFolder = sdkFolders.Single(); + var versionFile = Path.Combine(sdkFolder, ".version"); + + var lines = File.ReadAllLines(versionFile); + DotnetRidUnderTest = lines[2].Trim(); } }