Dyl*_*ill 12 asp.net-mvc nuget-package-restore visual-studio-2015
我使用Visual Studio 2015的GitHub扩展将我的项目克隆到新计算机上.我尝试恢复包,我收到一个错误,说:
NuGet Package restore failed for project PROJECT: Unable to find version 2.0.0 of package 'Microsoft.Net.Compilers'
Run Code Online (Sandbox Code Playgroud)
我已经研究了其他一些类似问题的问题,但这些解决方案都没有对我有用.
我尝试删除packages文件夹,再次打开Visual Studios,然后重建.那并没有解决它.
我尝试在Package Manager Console中手动安装Microsoft.Net.Compilers.
PM> Install-Package Microsoft.Net.Compilers
Run Code Online (Sandbox Code Playgroud)
我尝试从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>
Run Code Online (Sandbox Code Playgroud)
我尝试重新安装所有包
Update-Package –reinstall
Run Code Online (Sandbox Code Playgroud)
到目前为止,我没有运气解决问题.任何帮助表示赞赏.
编辑:
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
Run Code Online (Sandbox Code Playgroud)
它还促使我恢复包.当我点击恢复时,我得到了和往常一样的错误.
Vin*_*nod 15
根据您的错误消息,您似乎正在寻找不再存在的版本,并且无法分辨您选择的Package源.我觉得你正在寻找nuget.org存储库中没有的2.0.0版本.最新版本是2.0.0-rc,它是预发布候选版本.
如果您想获得最新版本,请尝试此命令
Install-Package -Id Microsoft.Net.Compilers -Version 2.0.0-rc -Source nuget.org
Run Code Online (Sandbox Code Playgroud)
如果您需要最新的稳定版本(1.3.2),请尝试此命令
Install-Package -Id Microsoft.Net.Compilers -Version 1.3.2 -Source nuget.org
Run Code Online (Sandbox Code Playgroud)
更新 如果仍然无法安装包,那么package.config,packages/folder和.csproj文件之间的包可能不同步
请按照以下步骤执行手动清理
作为第2步的一部分,您可能必须从.csproj中删除的一些条目就是这些条目
<Import Project="..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.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('..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props'))" />
</Target>
Run Code Online (Sandbox Code Playgroud)
Taw*_*kil 15
在全新安装 Visual Studio 2017 后,我遇到了类似的错误,必须执行以下操作才能使其成功自动恢复丢失的 NuGet 包。在 VS 中,转到“工具 > 选项 > NuGet 包管理器 > 包源”,并确保显示并选中相应的包源。
见下文。顶部添加的 nuget.org 包源告诉 VS 如果在本地计算机上找不到合适的版本,请在线从 NuGet 下载包。
| 归档时间: |
|
| 查看次数: |
34393 次 |
| 最近记录: |