The specified task executable location ......csc.exe is invalid error

Ha66y-Day picture Ha66y-Day · Jul 3, 2018 · Viewed 13.8k times · Source

I have a project on TFS that is working on everyone else's machine, except mine. When building I get the error that can be seen in the image. "The specified task executable location csc.exe is invalid." currently trying to repair VS 2017 now.

Answer

Andy Li-MSFT picture Andy Li-MSFT · Jul 4, 2018

Based on the message, seems the csc.exe is damaged.

Just try below things to narrow down the issue:

  • Navigate to the Microsoft.Net.Compilers package location, delete the package folder, then rebuild. Generally the package will be restored automatically during the build.

    YOUR_PROJECT_DIR\packages\Microsoft.Net.Compilers.2.6.1

  • Uninstall and Re-install the Microsoft.Net.Compilers package:

    1. Open Visual Studio
    2. Go to Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution
    3. Go to Installed tab and find Microsoft.Net.Compilers package
    4. Uninstall the package from your project
    5. Try to build your project now. (Thus it will use the default compiler which lives in the .NET framework folder: C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe)
    6. If you really need the Microsoft.Net.Compilers package then go ahead and find it in the Browse tab and install the latest stable version.
    7. Build the project and if everything works, make sure you commit changes to your code repository.
  • You can also try to run below command to uninstall and reinstall the Nuget packages from the Package Manager Console: See Microsoft.Net.Compilers

    Uninstall-Package Microsoft.Net.Compilers -Version 2.6.1

    Install-Package Microsoft.Net.Compilers -Version 2.6.1