The fault came down to this line in the visual studio project:
<Content Include="**\*.html" />
One of the file paths was 165 characters longs, shortening the file path fixed the problem. It doesn't explain why the deployment worked in Visual Studio and not on Team City, but at least it works everywhere now.