NuGet包在visual studio 2015和Xamarin中引起麻烦

Itz*_*der 7 c# android nuget nuget-package visual-studio-2015

我正在尝试使用Xamarin和Visual Studio 2015与另一位拥有源代码控制权限的朋友创建一个Android应用程序.

一切都很顺利,直到我的朋友添加了一个项目并且他使用了NuGet包.

在我激活获取最新版本并尝试构建解决方案后,我收到了错误消息:

Severity    Code    Description Project File    Line
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\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props.    iBuy.API    C:\Users\?????\Source\Workspaces\iBuy\IBuy\iBuy.API\iBuy.API.csproj 164
Run Code Online (Sandbox Code Playgroud)

我查找了一些针对此问题的解决方案并尝试卸载Microsoft.CodeDom.Providers.DotNetCompilerPlatform和Microsoft.Net.Compilers包并重新安装它们但它没有帮助.我的解决方案中甚至没有\ packages\Microsoft.Net.Compilers.1.0.0\build文件夹.

NuGet包还原中的所有内容都已经过检查,我的解决方案中没有任何".nuget"文件.

我该怎么做才能消除该错误消息?

先感谢您!

Mat*_*ard 13

由于您没有.nuget\NuGet.targets文件,因此将出现该错误消息.

要修复它,您可以停止使用基于MSBuild的NuGet包还原或将.nuget/NuGet.targets文件添加到源代码管理.

NuGet团队不推荐使用基于MSBuild的NuGet包还原.它为项目文件(.csproj)添加了一些额外的元素:

<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>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
Run Code Online (Sandbox Code Playgroud)

您可以在EnsureNuGetPackageBuildImports目标元素中包含更多项目.您可以从项目文件中删除它们,而是依赖Visual Studio来恢复NuGet包.