【问题标题】:xamarin git pull nuget package errorxamarin git pull nuget 包错误
【发布时间】:2018-06-13 10:44:25
【问题描述】:

我是 Xamarin android 开发的新手。

我从 git 中提取代码。

之后,我在 Visual Studio 中打开了我的解决方案。

我清理了解决方案 - 现在一切正常。

然后我尝试构建显示错误的解决方案。

>Restoring NuGet packages...
To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages during build.'
NuGet Package restore failed for project app: Unable to find version '2.0.0' of package 'FastAndroidCamera'.
  C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'FastAndroidCamera.2.0.0' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
  https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.
  An error occurred while sending the request.
  The remote name could not be resolved: 'api.nuget.org'
1>------ Rebuild All started: Project: app, Configuration: Debug Any CPU ------
1>D:\PRANAV\TOLL\GIT\MobileApp-12-06-2018\MobileApp\app\app.csproj(467,5): error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Xamarin.Build.Download.0.4.3\build\Xamarin.Build.Download.props.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========\

这是我得到的错误。所以大家能弄清楚我在哪里做错了吗?

【问题讨论】:

  • 看起来 NuGet 无法解析 api.nuget.org。您是否尝试过重新启动 Visual Studio 并且可以访问 api.nuget.org/v3/index.json
  • 已完成但同样的错误\存在
  • 我试图恢复 nuget 但同样的问题..
  • 再检查一下,运行 Visual Studio 的计算机是否已连接到 Internet 并能够访问 api.nuget.org/v3/index.json
  • 我试图在浏览器上运行它,我得到一个 json

标签: c# git visual-studio xamarin nuget


【解决方案1】:

根据报错信息,

要防止 NuGet 在构建过程中恢复包,请打开 Visual Studio Options 对话框,单击 Package Manager 节点并取消选中 '允许 NuGet 在构建期间下载丢失的包。'

该项目似乎使用了旧的现在已弃用的 NuGet 包还原,它基于 MSBuild,并在每次构建时运行 NuGet.exe。这些消息来自NuGet.exe

查看类似问题here

要解决此问题,您应该确保升级到最新版本的 NuGet,它会自动进行包还原,而不是基于 MSBuild 的 NuGet 包还原。

您将要删除 NuGet 目标(删除 .nuget 文件夹,然后手动编辑您的 .csproj 文件并删除导入 NuGet.targets 文件的行)。这不再需要。使用新的方式恢复 nuget 包,NuGet 包将在构建之前由 Visual Studio 自动恢复。

有关更多信息,请参阅 David Ebbo 的这篇文章:http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html 和博客 how to switch from "Enable Package Restore" to "Automatic Package Restore"

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-13
    • 1970-01-01
    • 1970-01-01
    • 2012-06-17
    • 2020-03-21
    • 1970-01-01
    • 2013-11-12
    • 1970-01-01
    相关资源
    最近更新 更多