diff --git a/src/Microsoft.DotNet.Helix/Sdk/CreateXHarnessAndroidWorkItems.cs b/src/Microsoft.DotNet.Helix/Sdk/CreateXHarnessAndroidWorkItems.cs index 88a3049415c..f4c636aec9d 100644 --- a/src/Microsoft.DotNet.Helix/Sdk/CreateXHarnessAndroidWorkItems.cs +++ b/src/Microsoft.DotNet.Helix/Sdk/CreateXHarnessAndroidWorkItems.cs @@ -23,9 +23,9 @@ public static class MetadataNames public const string ApkPath = "ApkPath"; } - private const string PosixAndroidWrapperScript = "xharness-helix-job.android.sh"; - private const string NonPosixAndroidWrapperScript = "xharness-helix-job.android.ps1"; - private const string NonPosixAndroidHeaderScript = "xharness-helix-job.android.header.ps1"; + private const string PosixAndroidScript = "xharness-helix-job.android.sh"; + private const string NonPosixAndroidScript = "xharness-helix-job.android.ps1"; + private const string NonPosixAndroidWrapperScript = "xharness-runner.android.ps1"; /// /// Boolean true if this is a posix shell, false if not. @@ -111,7 +111,7 @@ private async Task PrepareWorkItem(IZipArchiveManager zipArchiveManag if (!IsPosixShell) { // For windows, we need to add a .ps1 header to turn the script into a cmdlet - customCommands = GetPowerShellHeader() + customCommands; + customCommands = WrapCustomCommands(customCommands); } string workItemZip = await CreatePayloadArchive( @@ -126,7 +126,7 @@ private async Task PrepareWorkItem(IZipArchiveManager zipArchiveManag { // WorkItem payloads of APKs can be reused if sent to multiple queues at once, // so we'll always include both scripts (very small) - PosixAndroidWrapperScript, NonPosixAndroidWrapperScript + PosixAndroidScript, NonPosixAndroidScript }); return CreateTaskItem(workItemName, workItemZip, command, workItemTimeout); @@ -168,7 +168,7 @@ private string GetHelixCommand( appPackage.TryGetMetadata(MetadataNames.AndroidInstrumentationName, out string androidInstrumentationName); appPackage.TryGetMetadata(MetadataNames.DeviceOutputPath, out string deviceOutputPath); - string wrapperScriptName = IsPosixShell ? PosixAndroidWrapperScript : NonPosixAndroidWrapperScript; + string wrapperScriptName = IsPosixShell ? PosixAndroidScript : NonPosixAndroidScript; string xharnessHelixWrapperScript = IsPosixShell ? $"chmod +x ./{wrapperScriptName} && ./{wrapperScriptName}" : $"powershell -ExecutionPolicy ByPass -NoProfile -File \"{wrapperScriptName}\""; @@ -188,12 +188,12 @@ private string GetHelixCommand( return xharnessRunCommand; } - private static string GetPowerShellHeader() + private static string WrapCustomCommands(string customCommands) { using Stream stream = ZipArchiveManager.GetResourceFileContent( - ScriptNamespace + NonPosixAndroidHeaderScript); + ScriptNamespace + NonPosixAndroidWrapperScript); using StreamReader reader = new(stream); - return reader.ReadToEnd(); + return reader.ReadToEnd().Replace("<#%%USER COMMANDS%%#>", customCommands); } } } diff --git a/src/Microsoft.DotNet.Helix/Sdk/Microsoft.DotNet.Helix.Sdk.csproj b/src/Microsoft.DotNet.Helix/Sdk/Microsoft.DotNet.Helix.Sdk.csproj index e689a1f9cc1..d832bd60e6d 100644 --- a/src/Microsoft.DotNet.Helix/Sdk/Microsoft.DotNet.Helix.Sdk.csproj +++ b/src/Microsoft.DotNet.Helix/Sdk/Microsoft.DotNet.Helix.Sdk.csproj @@ -36,15 +36,15 @@ Never - - Never - Never Never + + Never + Never diff --git a/src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-helix-job.android.header.ps1 b/src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-runner.android.ps1 similarity index 93% rename from src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-helix-job.android.header.ps1 rename to src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-runner.android.ps1 index e91764050f2..d5105ac2e2f 100644 --- a/src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-helix-job.android.header.ps1 +++ b/src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/xharness-runner.android.ps1 @@ -40,3 +40,10 @@ function report_infrastructure_failure($message) { $message -replace "['\\]" | Out-File -FilePath "$Env:HELIX_WORKITEM_ROOT\.reboot" } +# User commands begin here + +<#%%USER COMMANDS%%#> + +# User commands end here + +exit $LASTEXITCODE