Building VS project in WSL in GitHub actions

I have a PowerShell script that builds the VS project in WSL in my local machine. But, when I push the same script into Github actions, I get an error. It is not the issue with visual studio because it is building without any error in WSL. It’s not compiling and creating the object files. Can anyone please help me with this issue? The sample of error is as follows:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\Linux.WSL.targets(250,5): error MSB4018: liblinux.Local.Shell.WindowsSubsystemShellException: Could not open windows subsystem shell —> liblinux.Local.Shell.WindowsSubsystemShellException: Failed to start WSL process —> liblinux.Local.Shell.WindowsSubsystemShellException: Echo command failing
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\Linux.WSL.targets(250,5): error MSB4018: at liblinux.Local.Shell.WindowsSubsystemShell.VerifyEcho(TimeSpan timeout)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\Linux.WSL.targets(250,5): error MSB4018: at liblinux.Local.Shell.WindowsSubsystemShell.StartWSLProcess(TimeSpan timeout)

Here is my yaml file:
name: Build Linux
on: [ push ]
jobs:
Build-EMX:
runs-on: [ self-hosted, windows ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Building demo in wsl
run: powershell .\build.ps1