错误:ResolveLibraryProjectImports任务意外失败

7
我在使用VS2017和Xamarin编译Android项目时遇到了错误。其中一个错误提示是字符串类型不允许,建议更新所有的Xamarin.Android引用。我发现有一个与Xamarin.Core中的可观察对象相关的引用,于是我安装了它。但自那以后,我一直遇到解析错误。我尝试删除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       

我还尝试了修复VS2017,但没有任何效果。 - Tom Magaro
您可以在Bugzilla中检查此问题,问题是指定的路径、文件名或两者都太长。,有几种方法可以解决您的问题,您可以进行检查。 - Grace Feng
我已经尝试了Bugzilla上提到的所有方法,但仍然收到错误提示。 - Tom Magaro
可能是[“ResolveLibraryProjectImports”任务意外失败]的重复问题(https://dev59.com/aVcP5IYBdhLWcg3w8udi)。 - testing
5个回答

4

3

0
当我通过NuGet向我的项目添加对Xamarin.GooglePlayServices.Ads的引用时,我遇到了这个问题。 就在我这样做的时候,我和OP遇到了相同的问题。 将我的代码移动到C驱动器的根目录也没有帮助,但是根据Alper Ebicoglu的建议,我添加了...
<UseShortFileNames>True</UseShortFileNames>

...将其添加到我的构建配置属性组的项目文件中。在Visual Studio中重新加载项目后,我成功地构建了项目。

希望这可以帮助到您!


0

我刚在另一个SO问题上回答了这个问题 (https://dev59.com/aVcP5IYBdhLWcg3w8udi#44780549)。

问题的关键是,如果您的解决方案保存在路径很长的位置,则某些文件的路径可能会超过Windows的最大限制(260个字符)

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


0

我也遇到了同样的问题,以下是我解决的方法:

  1. 重新启动Visual Studio
  2. 打开项目
  3. 清理解决方案
  4. 重新生成解决方案
  5. 关闭解决方案
  6. 重新打开项目

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接