Mister Epic Mister Epic - 1 year ago 105
ASP.NET (C#) Question

Website publish failing due to file path being too long

I am trying to publish a Website project from a vendor that has ridiculously long paths to some of its files. When publishing, the error is:

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

When I publish, Visual Studio 2012 Update 3 is attempting to write to a temp directory, and the prefix is quite long:


I thought I might be able to redirect VS to a different temporary directory at
by following this SO answer: Temp path too long when publishing a web site project

I create my publication profile, and as soon as I open it, there is an error indicating that
is not an element of
. Regardless, I updated the file so it looks like this:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />

When I try to publish, I get the a modal box pop-up entitled "File Modification Detected", with the message "The project YourWebsite has been modified outside the environment", and it asks me if I want to reload. In my error list, I continue to get the error about the path being too long, as it is not attempting to use the
directory I identified.

I need to put this bloody thing onto a server, I am up for any solution that allows me to publish the bloody thing. I don't know much about the Website project template, so please let me know if there is a better way.

Answer Source

From http://forums.asp.net/t/1944241.aspx?Website+publish+failing+due+to+file+path+being+too+long

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


You can likely make the above path C:\temp or ......\Temp (as needed to get it as close to root of the drive as possible.

In my case, there was no .csproj or .vbproj (website project file) but there was a website.publishproj file that warns you not to edit it, but I did anyway, and it did the trick.