Skip to content

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

Open
rolfbjarne wants to merge 4 commits intomainfrom
dev/rolf/launch-env-vars
Open

[dotnet] Add support for @(RuntimeEnvironmentVariable).#24824
rolfbjarne wants to merge 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
Copy link
Collaborator

🔥 [CI Build #0e7614e] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 27 tests failed, 129 tests passed.

Failures

❌ monotouch tests (MacCatalyst) [attempt 3]

15 tests failed, 0 tests passed.

Failed tests

  • monotouch-test/Mac Catalyst/Debug: BuildFailure
  • monotouch-test/Mac Catalyst/Debug (ARM64): BuildFailure
  • monotouch-test/Mac Catalyst/Debug (managed static registrar): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Debug (static registrar): BuildFailure
  • monotouch-test/Mac Catalyst/Debug (static registrar, ARM64): BuildFailure
  • monotouch-test/Mac Catalyst/Release (managed static registrar): BuildFailure
  • monotouch-test/Mac Catalyst/Release (managed static registrar, all optimizations): BuildFailure
  • monotouch-test/Mac Catalyst/Release (NativeAOT): BuildFailure
  • monotouch-test/Mac Catalyst/Release (NativeAOT, ARM64): BuildFailure
  • monotouch-test/Mac Catalyst/Release (NativeAOT, x64): BuildFailure
  • monotouch-test/Mac Catalyst/Release (static registrar): BuildFailure
  • monotouch-test/Mac Catalyst/Release (static registrar, all optimizations): BuildFailure
  • monotouch-test/Mac Catalyst/Release (ARM64, LLVM): BuildFailure
  • monotouch-test/Mac Catalyst/Debug (interpreter): BuildFailure
  • monotouch-test/Mac Catalyst/Release (interpreter): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))

Html Report (VSDrops) Download

❌ monotouch tests (macOS) [attempt 3]

12 tests failed, 0 tests passed.

Failed tests

  • monotouch-test/macOS/Debug: BuildFailure
  • monotouch-test/macOS/Debug (ARM64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Debug (managed static registrar): BuildFailure
  • monotouch-test/macOS/Debug (static registrar): BuildFailure
  • monotouch-test/macOS/Debug (static registrar, ARM64): BuildFailure
  • monotouch-test/macOS/Release (managed static registrar): BuildFailure
  • monotouch-test/macOS/Release (managed static registrar, all optimizations): BuildFailure
  • monotouch-test/macOS/Release (NativeAOT): BuildFailure
  • monotouch-test/macOS/Release (NativeAOT, ARM64): BuildFailure
  • monotouch-test/macOS/Release (NativeAOT, x64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Release (static registrar): BuildFailure
  • monotouch-test/macOS/Release (static registrar, all optimizations): BuildFailure

Html Report (VSDrops) Download

Successes

✅ 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 (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]

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.

5 participants