[dotnet] Add support for @(RuntimeEnvironmentVariable).#24824
[dotnet] Add support for @(RuntimeEnvironmentVariable).#24824rolfbjarne wants to merge 4 commits intomainfrom
Conversation
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
There was a problem hiding this comment.
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
RuntimeEnvironmentVariableSupportproject capability sodotnet runwill provide@(RuntimeEnvironmentVariable). - Wire
@(RuntimeEnvironmentVariable)into run/launch paths:mlaunch --setenvfor mobile targets andopen --envfor desktop targets. - Extend test harness to pass
dotnet run -earguments 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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #0e7614e] Build passed (Build packages) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #0e7614e] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #0e7614e] Build passed (Build macOS tests) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🔥 [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
Html Report (VSDrops) Download ❌ monotouch tests (macOS) [attempt 3]12 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
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:
@(RuntimeEnvironmentVariable)items android#10770dotnet run -e FOO=BARpasses@(RuntimeEnvironmentVariable)sdk#52664