项目 PROJECT 的 NuGet 包还原失败:无法找到包“Microsoft.Net.Compilers"的 2.0.0 版 [英] NuGet Package restore failed for project PROJECT: Unable to find version 2.0.0 of package 'Microsoft.Net.Compilers'

查看:69
本文介绍了项目 PROJECT 的 NuGet 包还原失败:无法找到包“Microsoft.Net.Compilers"的 2.0.0 版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Visual Studio 2015 的 GitHub 扩展将我的项目克隆到一台新计算机上.我尝试恢复软件包,但收到一条错误消息:

I used the GitHub extension of Visual Studio 2015 to clone my project onto a new computer. I try to restore packages and I get an error that says:

NuGet Package restore failed for project PROJECT: Unable to find version 2.0.0 of package 'Microsoft.Net.Compilers'

我已经调查了一些关于类似问题的其他问题,但这些解决方案都没有对我有用.

I've looked into some other questions about similar issues, but none of those solutions have worked for me yet.

我尝试删除包文件夹,再次打开 Visual Studios 然后重建.那并没有解决它.

I tried deleting the packages folder, opening up up Visual Studios again and then rebuilding. That didn't resolve it.

我尝试在包管理器控制台中手动安装 Microsoft.Net.Compilers.

I tried manually installing Microsoft.Net.Compilers in Package Manager Console.

 PM> Install-Package Microsoft.Net.Compilers

我尝试从 csproj 文件中删除这段代码(这似乎对某些人有用):

I tried removing this bit of code from the csproj file (this seemed to work for some):

    <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).nugetNuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir).nugetNuGet.targets'))" />
</Target>

我尝试使用

Update-Package –reinstall

到目前为止,我还没有运气解决这个问题.任何帮助表示赞赏.

So far I haven't had any luck resolving the issue. Any help is appreciated.

I tried the response below and received this error:

Install-Package : Some NuGet packages are missing from the solution. The packages need to be restored in order to build the dependency graph. Restore the packages before performing any operations.
At line:1 char:16
+ Install-Package <<<<  -Id Microsoft.Net.Compilers -Version 1.3.2 -Source nuget.org
    + CategoryInfo          : InvalidOperation: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetMissingPackages,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

它还提示我恢复软件包.当我点击恢复时,我得到了和往常一样的错误.

It also prompted me to restore packages. When I hit restore, I got the same error as usual.

推荐答案

根据您的错误消息,您似乎正在寻找一个不再存在的版本,并且无法判断您选择了哪个包源.我觉得您正在寻找 nuget.org 存储库中不可用的 2.0.0 版.最新的版本是 2.0.0-rc,它是预发布的候选版本.

Based on your error message looks like you are looking for a version that no longer exists and cannot tell which Package source you have selected. I feel like you are looking for version 2.0.0 which is not available in nuget.org repository. The latest one is 2.0.0-rc and it is pre release candidate.

如果您想获得最新版本,请尝试此命令

Please try this command if you want to get the latest version

Install-Package -Id Microsoft.Net.Compilers -Version 2.0.0-rc -Source nuget.org

如果你想要最新的稳定版本(1.3.2),试试这个命令

If you want the latest stable version (1.3.2), try this command

Install-Package -Id Microsoft.Net.Compilers -Version 1.3.2 -Source nuget.org

更新如果仍然无法安装该软件包,则该软件包可能在 packages.config、packages/文件夹和 .csproj 文件之间不同步

UPDATE If the package still cannot be installed, then that package may be out of sync between packages.config, packages/ folder and .csproj file

请按照以下步骤进行手动清理

Please follow these steps to perform manual cleanup

  1. 关闭视觉工作室.
  2. 在记事本或一些文本编辑器中打开 .csproj 并手动删除与 Microsoft.Net.Compilers 相关的所有条目
  3. 在记事本或一些文本编辑器中打开 packages.config 并删除 Microsoft.Net.Compilers 包的条目
  4. 转到 windows 资源管理器中的包/文件夹并删除 Microsoft.Net.Compilers 文件夹
  5. 现在启动 Visual Studio 并打开解决方案.
  6. 现在尝试再次安装该软件包.

作为第 2 步的一部分,您可能必须从 .csproj 中删除的一些条目是这些

Some of the entries that you may have to remove from .csproj as part of step 2 are these

<Import Project="..packagesMicrosoft.Net.Compilers.1.3.2uildMicrosoft.Net.Compilers.props" Condition="Exists('..packagesMicrosoft.Net.Compilers.1.3.2uildMicrosoft.Net.Compilers.props')" />

<NuGetPackageImportStamp></NuGetPackageImportStamp>

<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
        <PropertyGroup>
          <ErrorText>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 {0}.</ErrorText>
        </PropertyGroup>
        <Error Condition="!Exists('..packagesMicrosoft.Net.Compilers.1.3.2uildMicrosoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..packagesMicrosoft.Net.Compilers.1.3.2uildMicrosoft.Net.Compilers.props'))" />
</Target>

这篇关于项目 PROJECT 的 NuGet 包还原失败:无法找到包“Microsoft.Net.Compilers"的 2.0.0 版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆