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

Ale*_*akh 6 nuget xamarin xamarin-studio nuget-package-restore

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

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

Mat*_*ard 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>
Run Code Online (Sandbox Code Playgroud)

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

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

删除基于 MSBuild 的包还原并安装Xamarin Studio 的 NuGet 插件,并从 Xamarin Studio 内部使用包还原功能可能会更容易。要从 Xamarin Studio 中恢复,您可以右键单击该项目并选择“恢复包”。