Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for x86 specific runtime for testing #2815

Merged
merged 4 commits into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions eng/common/build.ps1
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -29,6 +30,7 @@ Param(
function Print-Usage() {
Write-Host "Common settings:"
Write-Host " -configuration <value> Build configuration: 'Debug' or 'Release' (short: -c)"
Write-Host " -platform <value> Platform configuration: 'x86', 'x64' or any valid Platform value to pass to msbuild"
Write-Host " -verbosity <value> 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"
Expand Down Expand Up @@ -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.
Expand All @@ -88,6 +91,7 @@ function Build {

MSBuild $toolsetBuildProj `
$bl `
$platformArg `
/p:Configuration=$configuration `
/p:RepoRoot=$RepoRoot `
/p:Restore=$restore `
Expand Down
8 changes: 4 additions & 4 deletions eng/common/dotnet-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Param(
[string] $verbosity = "minimal",
[string] $architecture = "",
[string] $version = "Latest",
[string] $runtime = "dotnet"
[string] $runtime = "dotnet",
[string] $installdir = Join-Path $RepoRoot ".dotnet"
)

. $PSScriptRoot\tools.ps1

try {
$dotnetRoot = Join-Path $RepoRoot ".dotnet"
InstallDotNet $dotnetRoot $version $architecture $runtime $true
InstallDotNet $installdir $version $architecture $runtime $true
}
catch {
Write-Host $_
Expand All @@ -19,4 +19,4 @@ catch {
ExitWithExitCode 1
}

ExitWithExitCode 0
ExitWithExitCode 0
38 changes: 34 additions & 4 deletions src/Microsoft.DotNet.Arcade.Sdk/src/InstallDotNetCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public class InstallDotNetCore : Task
public string DotNetInstallScript { get; set; }
[Required]
public string GlobalJsonPath { get; set; }
[Required]
public string Platform { get; set; }
[Required]
public string RepoRoot { get; set; }
vatsan-madhavan marked this conversation as resolved.
Show resolved Hide resolved

public override bool Execute()
{
Expand Down Expand Up @@ -55,7 +59,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)
{
Expand Down Expand Up @@ -96,16 +107,35 @@ public override bool Execute()
if(version != null)
{
string arguments = $"-runtime \"{runtimeItem.Key}\" -version \"{version.ToNormalizedString()}\"";
string installdir = Path.Combine(RepoRoot, ".dotnet");

string architecture = item.Value;
if (!string.IsNullOrWhiteSpace(architecture))
{
arguments += $" -architecture {architecture}";
if (string.Equals(architecture, "x86", StringComparison.OrdinalIgnoreCase))
{
installdir = Path.Combine(installdir, "x86");
}
}
else if (RuntimeInformation.OSArchitecture == Architecture.X86 ||
RuntimeInformation.OSArchitecture == Architecture.X64)
else
{
arguments += " -architecture x64";
if (!string.IsNullOrWhiteSpace(Platform) && !string.Equals(Platform, "AnyCpu", StringComparison.OrdinalIgnoreCase))
vatsan-madhavan marked this conversation as resolved.
Show resolved Hide resolved
{
arguments += $" -architecture {Platform}";
if (string.Equals(Platform, "x86", StringComparison.OrdinalIgnoreCase))
{
installdir = Path.Combine(installdir, "x86");
}
}
else if (RuntimeInformation.OSArchitecture == Architecture.X86 ||
RuntimeInformation.OSArchitecture == Architecture.X64)
{
arguments += " -architecture x64";
}
}
vatsan-madhavan marked this conversation as resolved.
Show resolved Hide resolved

arguments += $" -installdir {installdir}";
Log.LogMessage(MessageImportance.Low, $"Executing: {DotNetInstallScript} {arguments}");
var process = Process.Start(new ProcessStartInfo()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
Command="chmod +x &quot;$(_DotNetInstallScript)&quot;" />

<InstallDotNetCore
RepoRoot="$(RepoRoot)"
VersionsPropsPath="$(RepoRoot)eng\Versions.props"
GlobalJsonPath="$(RepoRoot)global.json"
DotNetInstallScript="$(_DotNetInstallScript)"/>
DotNetInstallScript="$(_DotNetInstallScript)"
Platform="$(Platform)"/>
</Target>

</Project>
5 changes: 4 additions & 1 deletion src/Microsoft.DotNet.Arcade.Sdk/tools/XUnit/XUnit.targets
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
<_TargetDir>$([System.IO.Path]::GetDirectoryName('$(_TestAssembly)'))\</_TargetDir>
<_CoreRuntimeConfigPath>$(_TargetDir)$(_TargetFileNameNoExt).runtimeconfig.json</_CoreRuntimeConfigPath>
<_CoreDepsPath>$(_TargetDir)$(_TargetFileNameNoExt).deps.json</_CoreDepsPath>
<_TestRunner>$(DotNetTool)</_TestRunner>

<_TestRunner Condition="'$(TestArchitectures)'!='' And '$(TestArchitectures)'!='AnyCpu' And Exists('$(DotNetRoot)$(TestArchitectures)\dotnet.exe')">$(DotNetRoot)$(TestArchitectures)\dotnet.exe</_TestRunner>
vatsan-madhavan marked this conversation as resolved.
Show resolved Hide resolved
<_TestRunner Condition="'$(_TestRunner)'==''">$(DotNetTool)</_TestRunner>

<_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)</_TestRunnerArgs>
</PropertyGroup>

Expand Down