Mister Epic Mister Epic - 4 months ago 41
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:

C:\Users\cuser\AppData\Local\Temp\WebSitePublish\MidasCMS400v9-1580334405\obj\Debug\Package\PackageTmp\


I thought I might be able to redirect VS to a different temporary directory at
c:\tem
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
WebPublishMethod
is not an element of
PropertyGroup
. Regardless, I updated the file so it looks like this:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>C:\Sites\MidasPublish</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
<AspnetCompileMergeIntermediateOutputPath>c:\tem\</AspnetCompileMergeIntermediateOutputPath>
</PropertyGroup>
</Project>


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
c:\tem
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

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.

<IntermediateOutputPath>..\Temp</IntermediateOutputPath>

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.