The problem can be fixed installing a Nuget package
Microsoft.Net.Compilers. Below is the link of my highlighted answer: Project builds fine with Visual Studio but fails from the command line
That feature is a syntactic sugar for C#6, try to install the latest
version of the framework 4.6.2
https://www.microsoft.com/en-us/download/details.aspx?id=53345Then go to your Project properties and change on the Application
option on Target framework to point to the latest. You don’t need to
change your code to replace the string interpolation with
string.Format method to fix it. If you are still getting this error,
is because, the compiler that is running your build is not the latest
version of C#, try to add the Microsoft.Net.Compilers, from Nuget and
compile again, that should resolve the issue. If you want to avoid to
install this package, try to open your .csproj and take a look on the
ToolsVersion.that should be pointing to the version 12, then change it
to 14, but make sure you have installed the latest version of the
MSBuild from
https://www.microsoft.com/en-us/download/details.aspx?id=48159 or go
to C:\Program Files (x86)\MSBuild\14.0\Bin, there you should have this
folder with the csc.exe compiler. If even then that doesn’t resolve
the issue, then try to follow this steps
https://msdn.microsoft.com/en-us/library/bb383985.aspx.
In my experience I solved this problem in 3 different ways:
1- just getting the package from Nuget
2- installing Microsoft Build Tools 2015 on the tfs server
3- The sledgehammer and last options but for me the best because you don’t need to deal with the dependency on nuget, is installing the visual studio version on the tfs server where you run the process.
Hope this helps