A project that compiles locally (targeting .NET Framework 4.6.1) fails on TeamCity with the following message:
[CoreCompile] Csc [Csc] Using shared compilation with compiler from directory: C:\Program Files (x86)\MSBuild\14.0\bin
[19:02:15][Csc] Services\MyFile.cs(20, 55): error CS1525: Invalid expression term 'int'
[19:02:15][Csc] Services\MyFile.cs(20, 59): error CS1003: Syntax error, ',' expected
I also get a lot of these in the failed compile in red writing:
[Step 5/9] The target "MvcBuildViews" listed in a BeforeTargets attribute at "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets (845,131)" does not exist in the project, and will be ignored.
Firstly, if it might help anybody, when TeamCity fails a step, a lot of text in that step will be red in color (even mere warnings), so at first I ran into a dead-end with believing the second error message was the problem. It wasn't.
Turns out, my Resharper 2016.3.2 (on Visual Studio 2017) had changed the following
int newInt;
if (!int.TryParse(theChar.ToString(), out newInt))
return false;
into
if (!int.TryParse(theChar.ToString(), out int newInt))
return false;
via an Alt+Enter refactoring called "Inline variable declaration" (which normally sounds pretty harmless) and I was like, well, ok then.
This was not causing any trouble locally, since it's a c# 7 syntax thing, but on my TeamCity build-agent the compiler would fail because of too low version of MSBuild.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With