【问题标题】:Error The "ResolveLibraryProjectImports" task failed unexpectedly错误“ResolveLibraryProjectImports”任务意外失败
【发布时间】:2017-05-30 19:39:58
【问题描述】:

我在尝试使用 Xamarin 在 VS2017 中编译 Android 项目时遇到错误。我收到了不允许的字符串类型错误,其中一个建议是更新我的所有 Xamarin.Android 引用。我找到了一个处理 Xamarin.Core 的 observables,所以我安装了它。从那以后,我一直收到分辨率错误。我已尝试删除 obj 和 bin 目录并重新启动 vs 和我的笔记本电脑。

这是错误的文本

Error       The "ResolveLibraryProjectImports" 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.PathHelper.GetFullPathName()
   at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 > maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32   >maxPathLength, Boolean expandShortPaths)
   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, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean >bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess >access, FileShare share)
   at System.IO.File.Open(String path, FileMode mode)
   at Xamarin.Tools.Zip.ZipEntry.DoExtract(IntPtr zipFile, String >destinationPath, FileMode outputFileMode, EntryExtractEventArgs args)
   at Xamarin.Tools.Zip.ZipEntry.Extract(String destinationDir, String >destinationFileName, FileMode outputFileMode)
   at Xamarin.Android.Tools.Files.ExtractAll(ZipArchive zip, String >destination, Action`2 progressCallback)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract   (DirectoryAssemblyResolver res, ICollection`1 jars, ICollection`1 >resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, >ICollection`1 resolvedEnvironments)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
   at >Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutio>nHost.Execute()
   at >Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()    LayoutExample.Android       

【问题讨论】:

标签: android xamarin visual-studio-2017


【解决方案1】:

https://forums.xamarin.com/discussion/92979/error-the-resolvelibraryprojectimports-task-failed-unexpectedly

问题来了: System.IO.PathTooLongException:指定的路径、文件名或两者都太长。完全限定的文件名必须少于 260 个字符,目录名必须少于 248 个字符。

尝试将您的项目移动到另一个位置,例如 "C:/" ,或者将项目名称更改为更简短的名称

【讨论】:

    【解决方案2】:

    解决方案是编辑您的 android 项目文件 (csproj),如下所示

    https://github.com/xamarin/AndroidSupportComponents/issues/51

    【讨论】:

      【解决方案3】:

      我刚刚在另一个 SO 问题 (https://stackoverflow.com/a/44780549/31580) 上回答了这个问题。

      关键在于,如果您的解决方案保存到路径较长的位置,那么这可能会导致某些文件的路径超过 Windows 的最大值(260 个字符)

      尝试将解决方案移至 C 或 D 的根目录(如果有的话)。

      【讨论】:

        【解决方案4】:

        有同样的问题。我就是这样解决的

        1. 重启 Visual Studio
        2. 打开项目
        3. 清洁溶液
        4. 重建解决方案
        5. 关闭解决方案
        6. 重新打开项目

        【讨论】:

          【解决方案5】:

          当我通过 NuGet 向我的项目添加对 Xamarin.GooglePlayServices.Ads 的引用时,我得到了这个。一旦我这样做了,我就遇到了与 OP 相同的问题。不幸的是,将我的代码移动到我的 C 驱动器的根目录也没有帮助;但是,根据 Alper Ebicoglu 的建议,我添加了...

          <UseShortFileNames>True</UseShortFileNames>
          

          ... 到我的构建配置的属性组中的项目文件。在 Visual Studio 中重新加载项目后,我能够构建我的项目。

          希望这会有所帮助!

          【讨论】:

            猜你喜欢
            • 2017-09-20
            • 2019-04-16
            • 1970-01-01
            • 2011-10-06
            • 1970-01-01
            • 1970-01-01
            • 2010-09-06
            • 2016-02-23
            • 2016-10-02
            相关资源
            最近更新 更多