diff --git a/eng/common/build.ps1 b/eng/common/build.ps1 index d7e3799ebd9..67046a43f8c 100644 --- a/eng/common/build.ps1 +++ b/eng/common/build.ps1 @@ -1,6 +1,7 @@ [CmdletBinding(PositionalBinding=$false)] Param( [string][Alias('c')]$configuration = "Debug", + [string]$platform = $null, [string] $projects, [string][Alias('v')]$verbosity = "minimal", [string] $msbuildEngine = $null, @@ -29,6 +30,7 @@ Param( function Print-Usage() { Write-Host "Common settings:" Write-Host " -configuration Build configuration: 'Debug' or 'Release' (short: -c)" + Write-Host " -platform Platform configuration: 'x86', 'x64' or any valid Platform value to pass to msbuild" Write-Host " -verbosity Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (short: -v)" Write-Host " -binaryLog Output binary log (short: -bl)" Write-Host " -help Print help and exit" @@ -77,6 +79,7 @@ function Build { InitializeCustomToolset $bl = if ($binaryLog) { "/bl:" + (Join-Path $LogDir "Build.binlog") } else { "" } + $platformArg = if ($platform) { "/p:Platform=$platform" } else { "" } if ($projects) { # Re-assign properties to a new variable because PowerShell doesn't let us append properties directly for unclear reasons. @@ -88,6 +91,7 @@ function Build { MSBuild $toolsetBuildProj ` $bl ` + $platformArg ` /p:Configuration=$configuration ` /p:RepoRoot=$RepoRoot ` /p:Restore=$restore ` diff --git a/eng/common/dotnet-install.ps1 b/eng/common/dotnet-install.ps1 index 5987943fd6f..0b629b8301a 100644 --- a/eng/common/dotnet-install.ps1 +++ b/eng/common/dotnet-install.ps1 @@ -8,9 +8,14 @@ Param( . $PSScriptRoot\tools.ps1 +$dotnetRoot = Join-Path $RepoRoot ".dotnet" + +$installdir = $dotnetRoot try { - $dotnetRoot = Join-Path $RepoRoot ".dotnet" - InstallDotNet $dotnetRoot $version $architecture $runtime $true + if ($architecture -and $architecture.Trim() -eq "x86") { + $installdir = Join-Path $installdir "x86" + } + InstallDotNet $installdir $version $architecture $runtime $true } catch { Write-Host $_ @@ -19,4 +24,4 @@ catch { ExitWithExitCode 1 } -ExitWithExitCode 0 \ No newline at end of file +ExitWithExitCode 0 diff --git a/src/Microsoft.DotNet.Arcade.Sdk/src/InstallDotNetCore.cs b/src/Microsoft.DotNet.Arcade.Sdk/src/InstallDotNetCore.cs index b49030a58b1..4f3cd294623 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/src/InstallDotNetCore.cs +++ b/src/Microsoft.DotNet.Arcade.Sdk/src/InstallDotNetCore.cs @@ -28,6 +28,8 @@ public class InstallDotNetCore : Task public string DotNetInstallScript { get; set; } [Required] public string GlobalJsonPath { get; set; } + [Required] + public string Platform { get; set; } public override bool Execute() { @@ -55,7 +57,14 @@ public override bool Execute() foreach (var runtime in dotnetLocalElement.EnumerateObject()) { var items = GetItemsFromJsonElementArray(runtime, out string runtimeName); - runtimeItems.Add(runtimeName, items); + if (runtimeItems.ContainsKey(runtimeName)) + { + runtimeItems[runtimeName] = runtimeItems[runtimeName].Concat(items); + } + else + { + runtimeItems.Add(runtimeName, items); + } } if (runtimeItems.Count > 0) { @@ -96,16 +105,25 @@ public override bool Execute() if(version != null) { string arguments = $"-runtime \"{runtimeItem.Key}\" -version \"{version.ToNormalizedString()}\""; + string architecture = item.Value; if (!string.IsNullOrWhiteSpace(architecture)) { arguments += $" -architecture {architecture}"; } - else if (RuntimeInformation.OSArchitecture == Architecture.X86 || - RuntimeInformation.OSArchitecture == Architecture.X64) + else { - arguments += " -architecture x64"; + if (!string.IsNullOrWhiteSpace(Platform) && !string.Equals(Platform, "AnyCpu", StringComparison.OrdinalIgnoreCase)) + { + arguments += $" -architecture {Platform}"; + } + else if (RuntimeInformation.OSArchitecture == Architecture.X86 || + RuntimeInformation.OSArchitecture == Architecture.X64) + { + arguments += " -architecture x64"; + } } + Log.LogMessage(MessageImportance.Low, $"Executing: {DotNetInstallScript} {arguments}"); var process = Process.Start(new ProcessStartInfo() { diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/InstallDotNetCore.targets b/src/Microsoft.DotNet.Arcade.Sdk/tools/InstallDotNetCore.targets index e1a2abfb15d..444a002de7e 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/InstallDotNetCore.targets +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/InstallDotNetCore.targets @@ -15,7 +15,8 @@ + DotNetInstallScript="$(_DotNetInstallScript)" + Platform="$(Platform)"/> diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/XUnit/XUnit.targets b/src/Microsoft.DotNet.Arcade.Sdk/tools/XUnit/XUnit.targets index b0f98d65d17..241ab2ea739 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/XUnit/XUnit.targets +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/XUnit/XUnit.targets @@ -47,7 +47,10 @@ <_TargetDir>$([System.IO.Path]::GetDirectoryName('$(_TestAssembly)'))\ <_CoreRuntimeConfigPath>$(_TargetDir)$(_TargetFileNameNoExt).runtimeconfig.json <_CoreDepsPath>$(_TargetDir)$(_TargetFileNameNoExt).deps.json - <_TestRunner>$(DotNetTool) + + <_TestRunner Condition="'%(TestToRun.Architecture)'=='x86' And Exists('$(DotNetRoot)x86\dotnet.exe')">$(DotNetRoot)x86\dotnet.exe + <_TestRunner Condition="'$(_TestRunner)'==''">$(DotNetTool) + <_TestRunnerArgs>exec --depsfile "$(_CoreDepsPath)" --runtimeconfig "$(_CoreRuntimeConfigPath)" $(TestRuntimeAdditionalArguments) "$(NuGetPackageRoot)xunit.runner.console/$(XUnitVersion)/tools/$(_TestRunnerTargetFramework)/xunit.console.dll" "$(_TestAssembly)" -noautoreporters -xml "%(TestToRun.ResultsXmlPath)" -html "%(TestToRun.ResultsHtmlPath)" $(_TestRunnerAdditionalArguments)