jueves, abril 25, 2024

Error en Visual Studio: Temp path too long when publishing a web site project

Publicando un sitio web desde .Net Visual Studio 2012 me generó un error por la longitud del archivo temporal donde se estaba compilando la versión del sito web. Este error indica que la ruta es muy larga para poder ser procesada. (Aplica también para las siguientes ediciones de Visual Studio)

El error que se muestra es:
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.

Para solucionar esto se debe de agregar en el archivo de publicación .pubxml la ruta donde queremos que se copien los archivos temporales que se van a generar, compilar o publicar. Este archivo se encuentra en la carpeta «App_Data/PublishProfiles«. Copie las siguientes líneas en el XML dentro de <PropertyGroup>.

<AspnetCompileMergeIntermediateOutputPath>
    C:\VS2012 Project\Temp
</AspnetCompileMergeIntermediateOutputPath>

En este ejemplo le indiqué que utilice la ruta C:\VS2012 Project\Temp pero bien puedes indicar la que gustes, siempre tomando en cuenta la longitud de la misma.

El archivo .pubxml se debería de ver similar a este. (Puede variar dependiendo de las opciones configuradas)

<Project ToolsVersion="4.0" 
    xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>
        Release
    </LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <publishUrl>
        C:\Desarrollo\MiProyecto\publish
    </publishUrl>
    <DeleteExistingFiles>False</DeleteExistingFiles>
    <AspnetCompileMergeIntermediateOutputPath>
      C:\VS2012 Project\Temp
    </AspnetCompileMergeIntermediateOutputPath>
    <PrecompileBeforePublish>True</PrecompileBeforePublish>
    <EnableUpdateable>True</EnableUpdateable>
    <DebugSymbols>False</DebugSymbols>
    <WDPMergeOption>CreateSeparateAssembly</WDPMergeOption>
    <UseFixedNames>True</UseFixedNames>
  </PropertyGroup>
</Project>

Después de este paso no deberíamos de tener problema publicando el sitio web.

Temp path too long when publishing a web site project
ASPNETCOMPILER(0,0): Error ASPRUNTIME
The specified path, file name, or both are too long
ASP.NET web site project

 

Roy Rojas
Roy Rojashttp://www.dotnetcr.com
Con más de 20 años de experiencia en programación, experto en lenguajes .NET, VB, C#, ASP.NET, Xamarin, XCode, DBA en SQL Server. Creador de dotnetcr.com, sitio web para programadores en español. royrojas.com | dotnetcr.com | GitHub
Roy Rojas
Roy Rojashttp://www.dotnetcr.com
Con más de 20 años de experiencia en programación, experto en lenguajes .NET, VB, C#, ASP.NET, Xamarin, XCode, DBA en SQL Server. Creador de dotnetcr.com, sitio web para programadores en español. royrojas.com | dotnetcr.com | GitHub