c# - NuGet 包导致 visual studio 2015 和 Xamarin 出现问题

标签 c# android nuget visual-studio-2015 nuget-package

我正尝试与另一个使用源代码控制的 friend 使用 Xamarin 和 Visual Studio 2015 创建一个 Android 应用程序。

一切都很顺利,直到我的 friend 添加了一个项目并且他使用了 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”文件。

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

提前致谢!

最佳答案

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

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

基于 MSBuild 的 NuGet 包还原已被 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 包。

关于c# - NuGet 包导致 visual studio 2015 和 Xamarin 出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32667227/

相关文章:

visual-studio-2015 - 此项目引用了该计算机上缺少的 NuGet 包。

c# - 环境变量作为 app.config 中的部分路径

c# - Azure Function - Cosmos DB 删除文档问题

android - 火力地堡错误 : W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms

android - 如何在 android 中使用 facebook SDK 在 facebook 中上传图像

nuget - NuGet包dll的+内容文件=失败?

c# - 从 Clearcase 的动态 View 将自定义控件 dll 添加到 Visual Studio 工具箱

c# - 关于在 WPF 中的 Canvas 中移动形状的一些事情

android - 关于Android包的书籍?

c# - 如何防止 Visual Studio 2017 添加对 NugetFallbackFolder 的引用