Batch command syntax error when runing gitlab-runner

Hello,
I am running gitlab runner on a local Windows computer. Config at the bottom.

When I run the unit test directly, as in: gitlab-runner exec shell test-unittest

Everything works, it compiles and tests.

However, when I run it automatically, as in: gitlab-runner run

I get the following error:

Time Elapsed 00:00:00.80
$ echo: testing…

testing...
$ dir /s /b RunnerUnitTest.dll | findstr /r bin\\ > tests_list.txt

$ for /f %f in (tests_list.txt) do vstest.console.exe "%f"

The syntax of the command is incorrect.
ERROR: Job failed: exit status 255

The first line is fine, just the second for loop at fault. But it runs from exec mode, it runs directly from the command line but not when running the whole stage. I have tried change %f to %%f too.

Here is the config

stages:

  • build
  • test

build-console:
stage: build
script:

  • ‘nuget restore’
  • ‘echo building…’
  • ‘msbuild.exe .\RunnerTest.sln’

test-unittest:
stage: test
script:

  • ‘echo: testing…’
  • ‘dir /s /b RunnerUnitTest.dll | findstr /r bin\ > tests_list.txt’
  • ‘for /f %f in (tests_list.txt) do vstest.console.exe “%f”’