diff --git a/Documentation/docs-mobile/building-apps/build-items.md b/Documentation/docs-mobile/building-apps/build-items.md
index 57cc85ce9af..73c3d3a51c6 100644
--- a/Documentation/docs-mobile/building-apps/build-items.md
+++ b/Documentation/docs-mobile/building-apps/build-items.md
@@ -567,3 +567,29 @@ this build action, see
These files are ignored unless the
[`$(EnableProguard)`](/xamarin/android/deploy-test/building-apps/build-properties#enableproguard)
MSBuild property is `True`.
+
+## RuntimeEnvironmentVariable
+
+`@(RuntimeEnvironmentVariable)` items allow environment variables to be
+passed to the Android application at runtime via `dotnet run -e`. For example:
+
+```sh
+dotnet run -e DOTNET_RUN_FOO=TestValue123 -e DOTNET_RUN_BAR=AnotherValue456
+```
+
+These items are automatically populated by the .NET SDK when using
+`dotnet run -e NAME=VALUE` and are included in the generated
+environment file during the build. Each item's `%(Identity)` is the
+variable name and `%(Value)` is the variable value.
+
+```xml
+
+
+
+```
+
+This feature is only available for Android application projects and
+requires a .NET SDK that supports the
+`RuntimeEnvironmentVariableSupport` project capability.
+
+This build item was introduced in .NET 10.0.300 SDK and .NET 11.
diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ProjectCapabilities.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ProjectCapabilities.targets
index a8b04059e23..fef1c290dfb 100644
--- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ProjectCapabilities.targets
+++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ProjectCapabilities.targets
@@ -17,6 +17,7 @@ Docs about @(ProjectCapability):
+
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs
index d5def237a9a..46fbc3ecae4 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs
@@ -131,20 +131,20 @@ public bool Publish (string target = null, string runtimeIdentifier = null, stri
return Execute (arguments.ToArray ());
}
- public bool Run (bool waitForExit = false, string [] parameters = null)
+ public bool Run (bool waitForExit = false, bool noBuild = true, string [] parameters = null)
{
string binlog = Path.Combine (Path.GetDirectoryName (projectOrSolution), "run.binlog");
var arguments = new List {
"run",
"--project", $"\"{projectOrSolution}\"",
- "--no-build",
- $"/bl:\"{binlog}\"",
- $"/p:WaitForExit={waitForExit.ToString (CultureInfo.InvariantCulture)}"
};
+ if (noBuild) {
+ arguments.Add ("--no-build");
+ }
+ arguments.Add ($"/bl:\"{binlog}\"");
+ arguments.Add ($"/p:WaitForExit={waitForExit.ToString (CultureInfo.InvariantCulture)}");
if (parameters != null) {
- foreach (var parameter in parameters) {
- arguments.Add ($"/p:{parameter}");
- }
+ arguments.AddRange (parameters);
}
return Execute (arguments.ToArray ());
}
@@ -153,7 +153,7 @@ public bool Run (bool waitForExit = false, string [] parameters = null)
/// Starts `dotnet run` and returns a running Process that can be monitored and killed.
///
/// Whether to use Microsoft.Android.Run tool which waits for app exit and streams logcat.
- /// Optional MSBuild properties to pass (e.g., "Device=emulator-5554").
+ /// Additional arguments to pass to `dotnet run`.
/// A running Process instance. Caller is responsible for disposing.
public Process StartRun (bool waitForExit = true, string [] parameters = null)
{
@@ -166,9 +166,7 @@ public Process StartRun (bool waitForExit = true, string [] parameters = null)
$"/p:WaitForExit={waitForExit.ToString (CultureInfo.InvariantCulture)}"
};
if (parameters != null) {
- foreach (var parameter in parameters) {
- arguments.Add ($"/p:{parameter}");
- }
+ arguments.AddRange (parameters);
}
return ExecuteProcess (arguments.ToArray ());
diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
index ae344755a58..f01393f6565 100644
--- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
+++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
@@ -1778,6 +1778,8 @@ because xbuild doesn't support framework reference assemblies.
<_GeneratedAndroidEnvironment Include="mono.enable_assembly_preload=0" Condition=" '$(AndroidEnablePreloadAssemblies)' != 'True' " />
<_GeneratedAndroidEnvironment Include="DOTNET_MODIFIABLE_ASSEMBLIES=Debug" Condition=" '$(AndroidIncludeDebugSymbols)' == 'true' and '$(AndroidUseInterpreter)' == 'true' " />
<_GeneratedAndroidEnvironment Include="DOTNET_DiagnosticPorts=$(DiagnosticConfiguration)" Condition=" '$(DiagnosticConfiguration)' != '' " />
+
+ <_GeneratedAndroidEnvironment Include="@(RuntimeEnvironmentVariable->'%(Identity)=%(Value)')" />