Add EnvironmentExtensions with RefreshEnvironmentVariables#19
Conversation
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/cd343de9-5264-4d19-938e-735deafdf229 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…tVariable Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/cd343de9-5264-4d19-938e-735deafdf229 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a new EnvironmentExtensions utility to PowerKit to refresh the current process environment by re-applying machine-level environment variables.
Changes:
- Introduces
EnvironmentExtensions.RefreshEnvironmentVariables()as an extension onEnvironment - Reads machine-level variables via
Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine)and writes them intoEnvironmentVariableTarget.Process
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…foreach Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/c1d2d00d-be11-46c6-a8d5-1707ec9d50e1 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…on non-Windows Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/aecbef3b-355c-4735-b2e4-3f82f17555be Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/3d8fa311-0f4c-4f8f-94bf-a6b79d0b081e Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/03328488-1e54-4559-bb21-56e797b4e583 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot what should we do about user-level variables? |
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/4d4d3f5e-2d67-4e48-828f-03ad5dc9c7fd Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Updated in 125c131. The method now reads both |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Ports
EnvironmentExtensions.RefreshEnvironmentVariablesfrom DotnetRuntimeBootstrapper into PowerKit.Changes
EnvironmentExtensions.cs— new extension onEnvironmentwith a single methodRefreshEnvironmentVariables()that fully synchronizes the current process environment with both machine-level and user-level environment variables: variables removed from machine or user scope are also removed from the process, machine-level variables are applied first, and user-level variables are applied on top (so user values win on key conflicts, matching Windows process-start behavior)The method is a no-op on non-Windows platforms (guarded via
OperatingSystem.IsWindows()).