Build VS project in WSL using github actions

I have the powershell script build.ps1 which builds the VS project in WSL. I can build and run fine in Visual Studio. But when I run the same powershell script in github actions, the build is failed. I don’t know if github actions doesn’t launch the WSL in visual studio? It shows the following error:
(ClCompile target) →
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\Linux.WSL.targets(264,5): error MSB4018: The “Compile” task failed unexpectedly.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\Linux.WSL.targets(264,5): error MSB4018: System.AggregateException: One or more errors occurred. —> 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(264,5): error MSB4018: at liblinux.Local.Shell.WindowsSubsystemShell.VerifyEcho(TimeSpan timeout)