NuGet包在Visual Studio 2015和Xamarin中引发问题

7

我正在尝试使用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

我查询了一些关于此问题的解决方法,并尝试卸载 Microsoft.CodeDom.Providers.DotNetCompilerPlatform 和 Microsoft.Net.Compilers 包,然后重新安装,但这并没有帮助。 我的解决方案中甚至没有 \packages\Microsoft.Net.Compilers.1.0.0\build 文件夹。 NuGet 包恢复中的所有内容都已经被检查过了,我的解决方案中也没有任何 ".nuget" 文件。 我该怎么做才能消除这个错误消息呢? 提前谢谢!
1个回答

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')" />

您的EnsureNuGetPackageBuildImports目标元素可能包含更多项。您可以从项目文件中删除它们,而依靠Visual Studio来恢复NuGet软件包。


给你一个拥抱和亲吻。 - Christopher Bonitz

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