Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Temp path too long when publishing a web site project

I am trying to publish an ASP.NET web site project using the Publish Web Site tool but get this error:

ASPNETCOMPILER(0,0): Error ASPRUNTIME: 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.

I see that it is trying to copy the files to a very long path in AppData:

Copying all files to temporary location below for package/publish:

C:\Users\imx0\AppData\Local\Temp\1\WebSitePublish\BMW.Web-424993535\obj\Debug\AspnetCompileMerge\Source.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /BMW.Web -p C:\Users\imx0\AppData\Local\Temp\1\WebSitePublish\BMW.Web-424993535\obj\Debug\AspnetCompileMerge\Source C:\Users\imx0\AppData\Local\Temp\1\WebSitePublish\BMW.Web-424993535\obj\Debug\AspnetCompileMerge\TempBuildDir

I couldn't find anything about this temp directory in my .pubxml publish profile. How can I change the temporary directory that Visual Studio copies the files to?

like image 331
Britton Avatar asked May 13 '13 15:05

Britton


3 Answers

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

<AspnetCompileMergeIntermediateOutputPath>c:\shortPath\</AspnetCompileMergeIntermediateOutputPath>
like image 169
Britton Avatar answered Oct 17 '22 10:10

Britton


  1. Go to your web project folder, navigate to Properties\PublishProfiles folder.
  2. open your profile file profile_name.pubxml (not the profile_name.pubxml.user)
  3. copy/past <AspnetCompileMergeIntermediateOutputPath>c:\shortPath\</AspnetCompileMergeIntermediateOutputPath> under the <PropertyGroup> tag
  4. save your file, you would be able to publish your website using this profil
like image 37
Abdu Avatar answered Oct 17 '22 10:10

Abdu


This is sort of an aside answer, but I ran into this problem when trying to MSBuild a solution that depended on nodeJS and gulp. The problem was that the gulp dependency tree became very deep and the aspnet_compiler was trying to copy that tree to a deeper directory, resulting in this error. I tried everything noted in here but nothing worked.

As it so happened, I was building with TFS, so my solution was to run an attrib +h node_modules\* /S /D before msbuild to hide the directory tree and then attrib +h node_modules\* /S /D. That did it for me.

Sure would be nice if the error thrown in this situation by the compiler revealed the path that caused the write to fail...

like image 12
Josh Avatar answered Oct 17 '22 09:10

Josh