I have tried many things today to get my build to work in Teamcity but to no avail.
Here is my setup.
I have 2 build configurations in TeamCity
Here's what I did to solve this
I already had this in my project file
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
But I needed to add this also
<Target Name="AfterBuild">
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />
</Target>
Doing this fixed the issue.
I hope this helps someone else who is working on TeamCity in the future.