The internal corerun host supports setting environment variables through a .env file via the --env option. Similarly, the .NET CLI run command has an (undocumented) feature called "environment directives," allowing environment variables to be passed in this format: dotnet '[env:FOO=1]' '[env:BAR=2]' run. These options are platform-agnostic, providing a unified syntax that bypasses platform-specific commands like set FOO=1, setx FOO=1, export FOO=1, setenv FOO=1 or $env:FOO=1.
Currently, in user-facing hosting such as corehost and nativeaot, no comparable platform-agnostic option exists. I’m opening this issue to gauge interest in introducing such a feature. 💡
Would adding --env or --dotnet-env next to the existing:
dotnet exec --roll-forward major my.dll
dotnet --roll-forward major my.dll
publish/my.exe --roll-forward major
make sense in both corehost and nativeaot?