locked
Problem to build sample project! RRS feed

  • Question

  • User18341 posted

    Hi i downloaded a calendar view sample project from this link, but when i compile a test project, i'm facing this error :

    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.PathHelper.GetFullPathName() at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITYATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at Ionic.Zip.ZipEntry.InternalExtract(String baseDir, Stream outstream, String password) at Ionic.Zip.ZipFile.InternalExtractAll(String path, Boolean overrideExtractExistingProperty) at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult) TestCalendarViewBackport

    i can build a source project correctly, but the test project could not build! Also i convert both project from API 10 (2.3.3) to API 15 (4.0.3) but still i'm facing the same problem!!!!

    Tuesday, July 23, 2013 12:10 AM

All replies

  • User1669 posted

    I'll give you a hint:

    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
    

    Shorten the directory path to your project. Example, go from:

    c:\some_incrediably_long_folder_path_that_goes_beyond_the_260_character_limit_that_is_common_among_numerious_development_environments_and_not_just_xamarin\MyProject.csroj

    to,

    c:\short_and_sweet\MyProject.csproj

    Tuesday, July 23, 2013 12:30 AM
  • User29117 posted

    I too have the same issue, and my projects are in a folder called "c:\work\labs_3rdParty\" should be short enough.

    Overall it appears that the issue is being caused by the generated filename which users have no control over. It's stupid for users to have to place a project on the root of C: in order for something to work. Perhaps the builder should convert paths to short on Windows platforms to get around this limitation

    Full error message: C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error XA0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com. Reason: System.IO.PathTooLongException: Path is too long. Path: C:_work\lab_3rdParty-xamarin\XamarinForms-Sample\Xamarin.FormsIntro\HelloXamarinFormsWorldXaml\HelloXamarinFormsWorldXaml\HelloXamarinFormsWorldXaml.Android\obj\Debug_libraryprojects\Xamarin.Forms.Platform.Android\libraryproject_imports/assets/ (XA0000) (HelloXamarinFormsWorldXaml.Android)

    public static String GetShortPathName(String longPath)
    {
        StringBuilder shortPath = new StringBuilder(longPath.Length + 1);
    
        if (0 == PathExtensions.GetShortPathName(longPath, shortPath, shortPath.Capacity))
        {
            return longPath;
        }
    
        return shortPath.ToString();
    }
    
    [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
    private static extern Int32 GetShortPathName(String path, StringBuilder shortPath, Int32 shortPathLength);
    
    Tuesday, January 27, 2015 4:09 PM
  • User4971 posted

    The path length is limited to around 120 characters or so because, as Damian said, the generated files in the obj directory use the path as a prefix in their file naming scheme. It's a limit that is too short and can trip you up, as it did me.

    Saturday, November 14, 2015 10:36 PM
  • User239753 posted

    Moving to another shorter directory fixed my problem, my original path wasn't extremely long though. The path giving the issue was a generated one, which remains something that should be changed to reduce the possibility of this problem?

    Friday, February 17, 2017 6:17 AM