Add a CodeMethod to extend System.Diagnostics.Process with and Environment property, returning a hashtable of the Environment variables for the process.
It would probably need to be a hashtable instance with a case sensitive comparer for OSX/Linux, as their environments' keys are CS.
@powercode I am interested on helping with this issue. First time contributor here
After a dive in the codebase I have a couple of points:
@renehernandez Yeah, that looks about the right place to put it.
I believe that those methods aren't applied to the Process objects as-is; instead, CodeProperty methods are applied as ETS methods to the objects when they're retrieved by the Get-Process cmdlet.
See here for how it's done with applying the Parent property to process objects, referencing the internal helper method:
@vexx32 Thanks, that solved the puzzle between the methods and the members of the Process object from the *-Process cmdlets.
I think I have enough to get started working on it
For what I have been reading, there is no standard implementation in .Net to get the runtime environment variables for a given process.
As far as existing properties in the Process class, the StartInfo property provides Environment and EnvironmentVariables properties which may store custom envvar applied before starting the process, but may be null otherwise.
The best line of development that I could find was to leverage the ideas and example from gapotchenko.
Any ideas?
@SteveL-MSFT @iSazonov do either of you fine folks have any experience in this area? A quick read through that blog post looks like it might require some p/invoke on Windows at the very least.
Perhaps we ought to check with the .NET Core folks to see if they have plans to fix this issue in the Process class itself. A quick search on the CoreFX repo seems to indicate it hasn't been raised as an issue there yet, if a search of the obvious keywords are any indication.
I think it should be implemented in CoreFX at first. Feel free to contribute there.
I agree with @iSazonov that I would start by raising the issue in corefx
Most helpful comment
@vexx32 Thanks, that solved the puzzle between the methods and the members of the Process object from the *-Process cmdlets.
I think I have enough to get started working on it