Build error is occurring since using Visual Studio 2015. When building in Visual Studio 2015 this is occurring rarely. When building in TeamCity this occurs very often.
This is probably an instance of this issue with Roslyn compiler. The workaround would be adding
False
under any node in .csproj file.