首页 > 解决方案 > Visual Studio 编译错误 - 计算机中缺少 nuget 包,但 nuget restore 说所有包都已安装?

问题描述

这是一个简单的错误,但令人沮丧?我的项目不会重建/编译。错误是:

Severity    Code    Description Project File    Line    Suppression State
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.2.1\build\Microsoft.Net.Compilers.props. Microsoft.Bot.Sample.LuisBot    C:\Users\jmatson\Downloads\retail-info-bot-src\Microsoft.Bot.Sample.LuisBot.csproj  229 

所以我尝试了一个 nuget restore 并得到:

All packages are already installed and there is nothing to restore. Time Elapsed: 00:00:00.0455939
========== Finished ==========

那么谁是对的,谁是错的,这又是如何解决的呢?:/

标签: c#visual-studiocompilationnuget

解决方案


Visual Studio 编译错误 - 计算机中缺少 nuget 包,但 nuget restore 说所有包都已安装?

首先,确保您没有将\packages文件夹添加到源代码管理中。如果您添加了它,请将其从源代码管理中删除。

其次,如果您没有使用源代码管理或没有将该文件夹添加到源代码管理中,但仍然存在此问题,则应删除Microsoft.Net.Compilers.1.2.1\packages文件夹中的包,然后在包管理器控制台中使用 NuGet 命令行:

Update-Package -reinstall

强制将包引用重新安装到项目中。

文件Microsoft.Net.Compilers.props位置更改或包文件夹中缺少文件将导致此问题。换句话说,该文件Microsoft.Net.Compilers.props缺少包文件夹但包在那里,您将收到该错误。

在这里检查类似的问题

希望这可以帮助。


推荐阅读