How to fix ASPNETCOMPILER(0,0): Error ASPRUNTIME: The specified path, file name, or both are too long

An Vu 20 Reputation points
2024-12-26T23:52:24.0866667+00:00

I keep having this error. Not sure how to fix it

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.

Here is my website.publishproj

<?xml version="1.0" encoding="utf-8"?>

<!--


website.publishproj

WARNING: DO NOT MODIFY this file, it is used for the web publish process.

Copyright (C) Microsoft Corporation. All rights reserved.


-->

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

<PropertyGroup>

<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

<ProductVersion>10.0.30319</ProductVersion>

<SchemaVersion>2.0</SchemaVersion>

<ProjectGuid>{8c515068-54b4-4645-968d-51735928149c}</ProjectGuid>

<!--<SourceWebPhysicalPath>$(MSBuildThisFileDirectory)</SourceWebPhysicalPath>-->

<SourceWebPhysicalPath>C:\Projects\RRP</SourceWebPhysicalPath>

<SourceWebVirtualPath>/RRP</SourceWebVirtualPath>

<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>

<SourceWebProject>http://localhost/RRP</SourceWebProject>

<SourceWebMetabasePath>/LM/W3SVC/1/ROOT/RRP</SourceWebMetabasePath>

</PropertyGroup>

<PropertyGroup>

<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

<!-- for VS2010 we need to use 10.5 but for VS2012+ we should use VisualStudioVersion -->

<WebPublishTargetsVersion Condition=" '$(WebPublishTargetsVersion)' =='' and '$(VisualStudioVersion)' == 10.0 ">10.5</WebPublishTargetsVersion>

<WebPublishTargetsVersion Condition=" '$(WebPublishTargetsVersion)'=='' ">$(VisualStudioVersion)</WebPublishTargetsVersion>

<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(WebPublishTargetsVersion)</VSToolsPath>

<_WebPublishTargetsPath Condition=" '$(_WebPublishTargetsPath)'=='' ">$(VSToolsPath)</_WebPublishTargetsPath>

<AssemblyFileVersion Condition="'$(AssemblyFileVersion)' == ''">1.0.0.0</AssemblyFileVersion>

<AssemblyVersion Condition="'$(AssemblyVersion)' == ''">1.0.0.0</AssemblyVersion>

</PropertyGroup>

<ItemGroup>

<AssemblyAttributes Include="AssemblyFileVersion">

  <Value>$(AssemblyFileVersion)</Value>

</AssemblyAttributes>

<AssemblyAttributes Include="AssemblyVersion">

  <Value>$(AssemblyVersion)</Value>

</AssemblyAttributes>

</ItemGroup>

<Import Project="$(_WebPublishTargetsPath)\Web\Microsoft.WebSite.Publishing.targets" />

</Project>

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,316 questions
0 comments No comments
{count} votes

Accepted answer
  1. Anna Xiu-MSFT 30,476 Reputation points Microsoft Vendor
    2024-12-27T02:39:40.2766667+00:00

    Hi @An Vu, 

    Welcome to Microsoft Q&A! 

    You can see the similar issue and add this to the publish profile file: 

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

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.