Skip to content

[dotnet] Add support for @(RuntimeEnvironmentVariable).#24824

Merged
rolfbjarne merged 4 commits intomainfrom
dev/rolf/launch-env-vars
Mar 9, 2026
Merged

[dotnet] Add support for @(RuntimeEnvironmentVariable).#24824
rolfbjarne merged 4 commits intomainfrom
dev/rolf/launch-env-vars

Conversation

@rolfbjarne
Copy link
Member

Add support for the '@(RuntimeEnvironmentVariable)' item group, which is set when using 'dotnet run' and passing environment variables using '-e|--environment NAME=VALUE' to 'dotnet run'.

This required adding the 'RuntimeEnvironmentVariableSupport' capability to tell 'dotnet run' that we support this.

References:

Add support for the '@(RuntimeEnvironmentVariable)' item group, which is set when using 'dotnet run' and passing environment variables using '-e|--environment NAME=VALUE' to 'dotnet run'.

This required adding the 'RuntimeEnvironmentVariableSupport' capability to tell 'dotnet run' that we support this.

References:

* dotnet/android#10770
* dotnet/sdk#52664
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for @(RuntimeEnvironmentVariable) (set by dotnet run -e|--environment NAME=VALUE) in the Apple .NET SDK targets so environment variables provided via dotnet run flow into the launched app (via mlaunch/open). This aligns Apple workloads with the behavior introduced in dotnet/android and dotnet/sdk.

Changes:

  • Add RuntimeEnvironmentVariableSupport project capability so dotnet run will provide @(RuntimeEnvironmentVariable).
  • Wire @(RuntimeEnvironmentVariable) into run/launch paths: mlaunch --setenv for mobile targets and open --env for desktop targets.
  • Extend test harness to pass dotnet run -e arguments and adjust the run test app/test accordingly.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/dotnet/UnitTests/ProjectTest.cs Updates the Run test to attempt covering both legacy RunEnvironment and dotnet run -e flows.
tests/dotnet/MyRunApp/AppDelegate.cs Adds an additional test case path to print environment variables to stdout.
tests/common/DotNet.cs Adds support for passing dotnet run -e NAME=VALUE via an environmentVariables dictionary.
msbuild/Xamarin.MacDev.Tasks/Tasks/GetMlaunchArguments.cs Updates env-var argument generation to support Value metadata items (for @(RuntimeEnvironmentVariable)).
dotnet/targets/Xamarin.Shared.Sdk.targets Adds RuntimeEnvironmentVariableSupport capability.
dotnet/targets/Microsoft.Sdk.Mobile.targets Includes @(RuntimeEnvironmentVariable) into MlaunchEnvironmentVariables.
dotnet/targets/Microsoft.Sdk.Desktop.targets Appends @(RuntimeEnvironmentVariable) to open arguments via --env.

You can also share your feedback on Copilot code review. Take the survey.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

rolfbjarne and others added 2 commits March 4, 2026 15:56
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #0e7614e] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 0e7614ec93b6f5228d71c645c5b3a6b8b81f1c84 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #0e7614e] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 0e7614ec93b6f5228d71c645c5b3a6b8b81f1c84 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #0e7614e] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 0e7614ec93b6f5228d71c645c5b3a6b8b81f1c84 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 0e7614ec93b6f5228d71c645c5b3a6b8b81f1c84 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne enabled auto-merge (squash) March 9, 2026 11:06
@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #0e7614e] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 156 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 6 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. [attempt 3] Html Report (VSDrops) Download
✅ monotouch (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 15 tests passed. [attempt 6] Html Report (VSDrops) Download
✅ monotouch (macOS): All 12 tests passed. [attempt 6] Html Report (VSDrops) Download
✅ monotouch (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 0e7614ec93b6f5228d71c645c5b3a6b8b81f1c84 [PR build]

@rolfbjarne rolfbjarne merged commit 8c327e9 into main Mar 9, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants