System.IO.PathTooLongException 在构建 Asp.Net 核心项目时
System.IO.PathTooLongException when building Asp.Net Core project
当我使用 Visual Studio 2016 update 3 Asp.Net 核心构建项目时,我收到此错误并且构建被终止:
严重性代码说明项目文件行抑制状态
错误 MSB4018 "FindConfigFiles" 任务意外失败。
System.IO.PathTooLongException: 指定的路径、文件名或两者都太长。完全限定文件名必须少于 260 个字符,目录名必须少于 248 个字符。
在 System.IO.Path.NormalizePath(字符串路径,布尔 fullCheck,Int32 maxPathLength,布尔 expandShortPaths)
在 System.IO.Path.GetDirectoryName(字符串路径)
在 System.IO.FileSystemEnumerableIterator1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler
1 resultHandler,布尔值 checkHost)
在 System.IO.Directory.EnumerateFiles(字符串路径)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func`2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherConfigFiles(字符串目录路径,字符串项目路径)
在 TypeScript.Tasks.FindConfigFiles.FindConfigFilesOnDisk()
在 TypeScript.Tasks.FindConfigFiles.Execute()
在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
在 Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() D:\weblFront\frontWeb\src\frontWeb\frontWeb.xproj C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\Microsoft.TypeScript.targets 156
我不使用任何工具等。只有Gulp。请问如何解决这个问题。
这看起来像是一个简单的错误,由路径(可能在依赖项中)对于 Windows 来说太长了。您只需使用代码缩短文件夹路径即可解决此问题。
例如尝试移动项目文件夹
来自 D:\weblFront\frontWeb\src\frontWeb\frontWeb\
到 D:\Code\frontWeb\
当我使用 Visual Studio 2016 update 3 Asp.Net 核心构建项目时,我收到此错误并且构建被终止:
严重性代码说明项目文件行抑制状态
错误 MSB4018 "FindConfigFiles" 任务意外失败。
System.IO.PathTooLongException: 指定的路径、文件名或两者都太长。完全限定文件名必须少于 260 个字符,目录名必须少于 248 个字符。
在 System.IO.Path.NormalizePath(字符串路径,布尔 fullCheck,Int32 maxPathLength,布尔 expandShortPaths)
在 System.IO.Path.GetDirectoryName(字符串路径)
在 System.IO.FileSystemEnumerableIterator1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler
1 resultHandler,布尔值 checkHost)
在 System.IO.Directory.EnumerateFiles(字符串路径)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func2 filter)
at TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(String directoryPath, String projectPath, Func
2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherFiles(字符串目录路径、字符串项目路径、Func`2 过滤器)
在 TypeScript.Tasks.FileHelpers.RecursiveGatherConfigFiles(字符串目录路径,字符串项目路径)
在 TypeScript.Tasks.FindConfigFiles.FindConfigFilesOnDisk()
在 TypeScript.Tasks.FindConfigFiles.Execute()
在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
在 Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() D:\weblFront\frontWeb\src\frontWeb\frontWeb.xproj C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\Microsoft.TypeScript.targets 156
我不使用任何工具等。只有Gulp。请问如何解决这个问题。
这看起来像是一个简单的错误,由路径(可能在依赖项中)对于 Windows 来说太长了。您只需使用代码缩短文件夹路径即可解决此问题。
例如尝试移动项目文件夹
来自 D:\weblFront\frontWeb\src\frontWeb\frontWeb\
到 D:\Code\frontWeb\