From c4cba16c268c65401d02d069146014807a46d1cb Mon Sep 17 00:00:00 2001 From: VS MobileTools Engineering Service 2 Date: Wed, 8 Mar 2023 04:46:32 -0500 Subject: [PATCH] [release/7.0.1xx-xcode14.2] [dotnet] Add support for passing environment variables and custom arguments when launching apps with mlaunch. (#17737) Environment variables can be specified using the MlaunchEnvironmentVariables item group, and any other mlaunch argument can be specified using the MlaunchAdditionalArguments item group. Also add support for the XamarinDebugPort and XamarinDebugHosts properties to make it easy to set the corresponding environment variable using the command line (since setting item groups using the command line isn't trivial). Fixes https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1755574. Backport of #17730 Co-authored-by: Rolf Bjarne Kvinge --- dotnet/targets/Xamarin.Shared.Sdk.targets | 7 +++++++ .../Tasks/GetMlaunchArgumentsTaskBase.cs | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index d1898bde5a..54ece1832c 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -1784,12 +1784,19 @@ <_MlaunchWaitForExit Condition="'$(_MlaunchWaitForExit)' == ''">true + + + + + (); public string DeviceName { get; set; } + public ITaskItem [] EnvironmentVariables { get; set; } = Array.Empty (); public string LaunchApp { get; set; } public string InstallApp { get; set; } public bool CaptureOutput { get; set; } // Set to true to capture output. If StandardOutput|ErrorPath is not set, write to the current terminal's stdout/stderr (requires WaitForExit) @@ -181,6 +183,12 @@ namespace Xamarin.iOS.Tasks { sb.AddQuoted (StandardErrorPath); } + foreach (var envvar in EnvironmentVariables) + sb.AddQuoted ("--setenv=" + envvar.ItemSpec); + + foreach (var arg in AdditionalArguments) + sb.AddQuoted (arg.ItemSpec); + if (WaitForExit) sb.Add ("--wait-for-exit");