Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The specified task executable "cmd.exe" could not be run.The specified executable is not a valid application for this OS platform

I am getting this weird error on Windows 10 when I try to build any project. The projects are working fine if I build them on other OS.

The specified task executable "cmd.exe" could not be run. The specified executable is not a valid application for this OS platform.

When I tried to check the log I got to the following code in Nuget.targets file inside .nuget folder, I commented the code and the project builds fine now. I don't understand why the error. Any new projects that I create are working fine...

I am using Visual Studio 2013 on Windows 8, Windows Server 2008 and Visual Studio 2015 on Windows 10.

Code:

<Exec Command="$(RestoreCommand)"
      LogStandardErrorAsError="true"
      Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
  • What is the reason for this error ?
  • Is it because of OS or because of Visual Studio ?
  • How do I resolve it? I don't think commenting the code is the way to do it...
like image 496
Syed Farjad Zia Zaidi Avatar asked Oct 14 '25 18:10

Syed Farjad Zia Zaidi


1 Answers

I got the same error, and repairing the corrupted files solved my issue. Try this:

  • In administrator command prompt, run sfc /scannow
  • It should emit log file in %windir%\Logs\CBS\CBS.log. Confirm that it repaired cmd.exe. For me I saw something like this Repairing corrupted file [ml:48{24},l:46{23}]"\??\C:\WINDOWS\SysWOW64"\[l:14{7}]"cmd.exe" from store
  • If that doesn't help you can try DISM /Online /Cleanup-Image /RestoreHealth
  • See more here
like image 155
ksp Avatar answered Oct 17 '25 13:10

ksp