Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toolrunner _argStringToArray eats up escaped quotes #648

Closed
saquibkhan opened this issue Jun 24, 2020 · 16 comments
Closed

toolrunner _argStringToArray eats up escaped quotes #648

saquibkhan opened this issue Jun 24, 2020 · 16 comments
Assignees

Comments

@saquibkhan
Copy link

saquibkhan commented Jun 24, 2020

Please check our current Issues to see if someone already reported this https://github.com/Microsoft/azure-pipelines-task-lib/issues

Environment

azure-pipelines-task-lib version:

Issue Description

toolrunner _argStringToArray eats up escaped quotes

Expected behavior

It should no remove escaped quotes

Actual behavior

toolrunner _argStringToArray eats up escaped quotes

Steps to reproduce

Server - Azure Pipelines
task DotNetCoreCLI@2

- task: DotNetCoreCLI@2
  inputs:
    command: 'test'
    arguments: '-- TestRunParameters.Parameter(name=\"EdiStagingFunctionsKey\",value=\"key2\")'

Other Inputs

  1. If we try passing quotes as a value even that is being eaten up by task-lib
    Input: -- TestRunParameters.Parameter(name=paramName,value=argwith"aquote)
    Output -- TestRunParameters.Parameter(name=paramName,value=argwithaquote)
  2. If we use backslash then also quote is eaten up.
    Input: -- TestRunParameters.Parameter(name=paramName,value=argwith\"aquote)
    Output -- TestRunParameters.Parameter(name=paramName,value=argwith\aquote)

Other Inputs:
Input: -- TestRunParameters.Parameter(name=\"EdiStagingFunctionsKey\",value=\"key2\")
Output: TestRunParameters.Parameter(name=\EdiStagingFunctionsKey\",value=\"key2\")
Note: Above the first escaped quotes are eaten up.

Input: TestRunParameters.Parameter(name="EdiStagingFunctionsKey",value="key2"
Output: TestRunParameters.Parameter(name=EdiStagingFunctionsKey,value=key2)

More details on the issue from customer - microsoft/azure-pipelines-tasks#13130

Our Debug analysis is as below along with the flow:
Issue Bug is with azure-task-lib _argStringToArray function - https://github.com/microsoft/azure-pipelines-task-lib/blob/master/node/toolrunner.ts#L88

Stack-->
https://github.com/microsoft/azure-pipelines-task-lib/blob/master/node/toolrunner.ts#L88
https://github.com/microsoft/azure-pipelines-task-lib/blob/master/node/toolrunner.ts#L838
https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/DotNetCoreCLIV2/dotnetcore.ts#L170

/cc @nohwnd @ShreyasRmsft @phanikmmsft

Logs

##[debug]C:\Program Files\dotnet\dotnet.exe arg: test
TestRunParameters.Parameter(name=\"EdiStagingFunctionsKey\",value=\"key2\")
##[debug]C:\Program Files\dotnet\dotnet.exe arg:  --logger trx --results-directory "C:\agent\_work\_temp" -- TestRunParameters.Parameter(name=\"EdiStagingFunctionsKey\",value=\"key2\")
##[debug]exec tool: C:\Program Files\dotnet\dotnet.exe
##[debug]arguments:
##[debug]   test
##[debug]   --logger
##[debug]   trx
##[debug]   --results-directory
##[debug]   C:\agent\_work\_temp
##[debug]   --
##[debug]   TestRunParameters.Parameter(name=\EdiStagingFunctionsKey",value="key2")
"C:\Program Files\dotnet\dotnet.exe" test --logger trx --results-directory C:\agent\_work\_temp -- "TestRunParameters.Parameter(name=\EdiStagingFunctionsKey\",value=\"key2\")"
##[debug]Exit code 0 received from tool 'C:\Program Files\dotnet\dotnet.exe'
##[debug]STDIO streams have closed for tool 'C:\Program Files\dotnet\dotnet.exe'
##[debug]BuildConfiguration=release
##[debug]BuildPlatform=any cpu
@github-actions
Copy link

This issue has had no activity in 90 days. Please comment if it is not actually stale

@github-actions github-actions bot added the stale label Sep 22, 2020
@nohwnd
Copy link
Member

nohwnd commented Sep 22, 2020

Yeah, still interested in this being fixed.

@github-actions
Copy link

This issue has had no activity in 90 days. Please comment if it is not actually stale

@kcentralsquare
Copy link

I am also interested in seeing this issue resolved. Please reopen @nohwnd @saquibkhan

@kcentralsquare
Copy link

Hello @nohwnd @ShreyasRmsft @phanikmmsft? This was closed over the holiday break, when I was not monitoring the email address subscribed. Definitely still need this issue resolved.

@ShreyasRmsft
Copy link
Member

@kcentralsquare could you open a new one? I am not a maintainer on this repo and do not have permissions to re-open this issue.

@mrsteamfist
Copy link

I am also having the same issue:
The test run parameter argument 'TestRunParameters.Parameter(name=\xxx", value="D:\a\1\s\out\xxx")' is invalid. Please use the format below.
Format: TestRunParameters.Parameter(name="", value="")
When I run:

  • task: DotNetCoreCLI@2
    displayName: Run xxx
    inputs:
    command: 'test'
    projects: '$(System.DefaultWorkingDirectory)\xxx'
    arguments: '--configuration release --framework net45 -- TestRunParameters.Parameter(name="xxx", value="$(System.DefaultWorkingDirectory)\out\xxxx")'

And idea when this will be fixed?

@kcentralsquare
Copy link

@ShreyasRmsft I'm not a maintainer either, nor will I create a new issue just because a bot closed this one. I didn't even create this issue in the first place. Who do we have to tag to get a response from microsoft?

@ShreyasRmsft
Copy link
Member

@egor-bryzgalov could you please help re-open this issue?

@egor-bryzgalov
Copy link
Member

@ShreyasRmsft yes, sure.

@github-actions github-actions bot removed the stale label Jan 22, 2021
@sudgarre
Copy link

sudgarre commented Mar 2, 2021

Any updates on this issue please ?

@ALM-at-RZL
Copy link

ALM-at-RZL commented Mar 17, 2021

WORKAROUND
Will work with ".NET Core"-Build-Task with Command "test" on on-premise server 2019.0.1. Later not tested. But maybe...

-- "TestRunParameters.Parameter(name=\\\"<name1>\\\", value=\\\"<value1>\\\")" "TestRunParameters.Parameter(name=\\\"<name2>\\\", value=\\\"<value2>\\\")"

@ALM-at-RZL
Copy link

After Update from 219.0.1 to 2020.0.1 the behavior has changed.
Will work with ".NET Core"-Build-Task with Command "test" on on-premise server 2020.0.1

-- "TestRunParameters.Parameter(name=\"<name1>\", value=\"<value1>\")" "TestRunParameters.Parameter(name=\"<name2>\", value=\"<value2>\")"

@ankit-arora12
Copy link

ankit-arora12 commented May 6, 2021

@egor-bryzgalov @damccorm There is a feedback ticket open for this https://developercommunity.visualstudio.com/t/DotNetCoreCLI2-test-task-doesnt-have-ca/1370232. We tried the workaround (\, \\\) but it did not help and we were still able to reproduce the issue. Can you please provide a fix for this?

@ALM-at-RZL
Copy link

The workaround above for 2019.0.1 and 2020.0.1 was running on agents in a VM with w2019-Server. Not tested on Linux-VMs - SRY

@fr4gles
Copy link

fr4gles commented Jun 11, 2021

We have tried multiple solutions

our case (job template):

  - task: DotNetCoreCLI@2
    displayName: ${{ format('run test {0}', parameters.testName) }}
    inputs:
      command: test
      arguments: --no-build --no-restore --verbosity $(Verbosity) --logger:"console;verbosity=detailed"
      projects: '$(ArtifactsPath)\**\$(TestName).dll'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests