4

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...
4
  • You'll need to get your machine fixed. The error message says that either c:\windows\system32\cmd.exe or c:\windows\syswow64\cmd.exe got corrupted. Commented Sep 9, 2015 at 5:18
  • @HansPassant But then why does it work if comment the code out? Also %windir%\system32\cmd.exe is working fine... Commented Sep 9, 2015 at 5:19
  • Not running the corrupt cmd.exe is a workaround. It is not nearly a solution. Commented Sep 9, 2015 at 5:21
  • 1
    @HansPassant I agree but I don't see how the cmd.exe is corrupt for VS if it's working fine... Commented Sep 9, 2015 at 5:23

5 Answers 5

4

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
Sign up to request clarification or add additional context in comments.

Comments

1

It happened to me when building my project on Windows 10. The problem was that the path of one file was very long (longer than 260 characters). So, by making it shorter, the problem solved for me.

1 Comment

@RKCoder I put 2-3 days on it last year !!
0

I had the same problem with VS c++ OpenFrameWorks. I tried your suggestion but could not solve the problem. I solved it differently as under. Soln: Project Properties -> Build Events ->Post-Build Event -> Command line "robocopy "$(OF_ROOT)/export/vs/$(Platform_Actual)/" "$(ProjectDir)bin/" "*.dll" /njs /njh /np /fp /bytes if errorlevel 1 exit 0 else exit %errorlevel%"

Removed Above line from command-line. OK, Solved.

Comments

0

If you started to face this error after deleting some files :

  • Unload your project
  • Edit Your csprok
  • Delete any reference for the your deleted files
  • Reload your project and Build

I faced the same issue when building a .NetCore App using a template that includes an Angular app with it, and i tried to delete the ClientApp folder. I had to remove multiple Target and ItemGroup tags from within the csproj.

Comments

0

To those who have landed here:

If you get this message I suggest that you do not, as @Hans Passant suggested, first assume that your machine or Windows has been corrupted.

Instead, I recommend that you suspect that your anti-virus or Carbon Black installation is to blame.

enter image description here

This was the case for me.

Someone from my IT Department disabled a certain Carbon Black policy and everything magically worked again.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.