Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity fails to build projects using C# 7

TeamCity is throwing errors when I added new the output variable syntax in our latest code update:

if (Enum.TryParse(input, out MyProject.ClassificationType classification))
{
    result.Classification = classification;
}

TeamCity threw this error:

[Csc] MyProject\MyCode.cs(125, 111): error CS1003: Syntax error, ',' expected

The code builds and runs fine in Visual Studio.

like image 945
Kcoder Avatar asked May 09 '17 22:05

Kcoder


2 Answers

MSBuild on the TeamCity Agent's machine was outdated to using Microsoft Build Tools 2015.

I was able to fix this by downloading and installing the new Build Tools for Visual Studio 2017 found here:

https://www.visualstudio.com/downloads/ -> Other Tools and Frameworks -> Build Tools for Visual Studio 2017 -> Download

Or bypass the spam by going here: https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15

Update TeamCity's build step to build using MSBuild 15 or Visual Studio 2017.

like image 178
Kcoder Avatar answered Oct 20 '22 03:10

Kcoder


Install the Build Tools for Visual Studio 2017 as suggested by Kcoder, adjust the build step in Team City afterwards (Example):

Switching to VS 2017 build inside Team City

In case you use MSBuild as the build step, you can adjust similar settings.

like image 30
Tore Aurstad Avatar answered Oct 20 '22 03:10

Tore Aurstad