Publishing project with files with very long names

Citing @Britton from Temp path too long when publishing a web site project:

Add this to your publish profile to modify the temporary directory for package/publish:

<AspnetCompileMergeIntermediateOutputPath>c:\shortPath\</AspnetCompileMergeIntermediateOutputPath>

Or according to Website publish failing due to file path being too long (citing @Jason Beck and @VeeKayBee):

Add the following line in default PropertyGroup of web project file:

<IntermediateOutputPath>..\Temp</IntermediateOutputPath>