如何在Mac OS X中的Xamarin Studio下启用Nuget包还原

时间:2014-04-12 17:45:09

标签: xamarin nuget xamarin-studio nuget-package-restore

我在Visual Studio下为我的项目启用了自动还原功能,但是当我切换到MAC和Xamarin Studio时,我无法恢复这些包:

xxx.csproj:错误:此项目引用此计算机上缺少的NuGet包。启用NuGet Package Restore以下载它们

1 个答案:

答案 0 :(得分:4)

通过启用自动恢复功能我假设您指的是基于MSBuild的恢复,它将NuGet.targets文件添加到您的项目中。

该特定错误来自MSBuild文件:

  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
  </Target>

错误情况表明找不到.nuget \ NuGet.targets文件。那么存在吗?路径的情况是否完全匹配?

另请注意,Mac上的NuGet.targets文件存在问题,因为它使用的是Mono上不支持的MSBuild功能。 codeplex提供的最新NuGet.targets文件可以解决此问题。

删除基于MSBuild的程序包还原并安装NuGet addin for Xamarin Studio可能更容易,并使用Xamarin Studio内部的程序包还原功能。要从Xamarin Studio中恢复,您可以右键单击该项目并选择Restore Packages。