[Feature Request] Allow response files to resolve the environment variables.
When using environment variables in command line, OS resolve these environment variables. Example:
# Windows
--token %token%
# Linux
--token $token
When trying to use the response file, the Environment Variables are not resolved and used as is.
Currently, System.Command enables the use of the [env:key=value] directive, allowing environment variables to be set from the command line during invocation.
Also, it support of resolving nesting response files for tokens prefixed by @.
It is nice if System.Command-line-api can support resolving the Environment Variables in response file based on OS .
Prior art
MSBuild supports environment variables in its response files, ever since the initial public commit. It uses Environment.ExpandEnvironmentVariables, which recognizes the %token% syntax on all operating systems.
In addition, MSBuild expands %MSBuildThisFileDirectory% to the path of the directory that contains the response file. That came from https://github.com/dotnet/msbuild/pull/4499.
@KalleOlaviNiemitalo This feature is not related to msbuild
i try to use the response file in cli tool using System.Command-line-api like
mycli -a name1 @token.rsp
token.rsp is like
-t %token% --account xyz
but %token% is not resolved and used as is
That is why i request this feature
If you reviewed the source code you will find no resolve for the environment variables at all.
Regex can be used for resolving the environment variables by modifying the method static IEnumerable
@moh-hassan, I understand System.CommandLine does not have this feature yet. I wanted to show how the similar feature in MSBuild works, so that the new feature in System.CommandLine can be made compatible with that.
I can provide PR for this feature if it is accepted.