본문 바로가기

Programming/Xamarin

System.IO.PathTooLongException 원인 및 해결방법

반응형

재현 스텝: 이름이 긴 Xamarin.Forms 설루션 생성 및 Android project build시 컴파일 에러로 발생

(해당 케이스의 경우 솔루션명이 26글자였음)

Detail :

Error The "Javac" task failed unexpectedly.
System.IO.PathTooLongException: 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.
at System.IO.LongPathHelper.Normalize(String path, UInt32 maxPathLength, Boolean checkInvalidCharacters, Boolean expandShortPaths) at
System.IO.Path.NewNormalizePath(String path, Int32 maxPathLength, Boolean expandShortPaths) at
System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) at
System.IO.Path.GetFullPathInternal(String path) at
System.IO.FileInfo.Init(String fileName, Boolean checkHost) at
System.IO.FileInfo.. ctor(String fileName) at
Xamarin.Android.Tasks.ZipArchiveEx.AddFiles(String folder, String folderInArchive) at
Xamarin.Android.Tasks.ZipArchiveEx.AddDirectory(String folder, String folderInArchive) at
Xamarin.Android.Tasks.Javac.Execute() at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackE nd.ITaskExecutionHost.Execute() at
Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() SimpleDistortionCorrection.Android

 

특정 파일의 FullName(경로 포함)이 너무 길어 발생하는 에러이다.

ref : https://docs.microsoft.com/en-us/xamarin/android/troubleshooting/questions/path-too-long-exception

 

How do I resolve a PathTooLongException error? - Xamarin

This article explains how to resolve a PathTooLongException that may occur while building an app.

docs.microsoft.com

위 링크에 따르면 에러가 발생하는 프로젝트의. csproj에 아래 두 가지를 시도해 보라고 한다.

<PropertyGroup>
    <UseShortFileNames>True</UseShortFileNames>
</PropertyGroup>
<PropertyGroup>
    <IntermediateOutputPath>C:\Projects\MyApp</IntermediateOutputPath>
</PropertyGroup>

 

위 두가지 모두 해결책은 아니었고 정확히 문제가 되는 부분을 찾기도 힘들어서 솔루션 네임을 줄여서 해결했다.

반응형