尽管答案很多,但我将添加另一个答案,恕我直言使事情变得更清晰。
如Rob和wrightmail所述,它Microsoft.Web.Infrastructure
是一个NuGet程序包(不需要链接,您可以在NuGet程序包管理器中找到它)。
显然,它已被您的项目引用,并突然消失了。可能存在多种原因,但重要的是,尽管您可以通过以下方式在Visual Studio中启用“自动打包还原”:
- 管理解决方案的NuGet程序包(解决方案资源管理器中的上下文菜单),
- 允许NuGet下载缺少的软件包(设置),
- 在Visual Studio(设置)中进行构建时自动检查缺少的软件包,
某些软件包可能需要手动重新安装。我不知道是什么让NuGet感到困惑,也许是手动删除引用,但这是我在这种情况下通常采用的解决方案。以下PM控制台有助于在保留原始版本的同时还原软件包(不更新为可能存在的新版本):
更新包Microsoft.Web.Infrastructure-重新安装
如果您不想意外地用较新的版本覆盖现有软件包,则可能需要保留版本,这可能会删除您在项目中使用的“旧”功能。
并且,作为一个证明,尽管有点冗长,但是版本没有改变,这是执行命令时的输出:
PM> Update-Package Microsoft.Web.Infrastructure -Reinstall
Attempting to gather dependencies information for multiple packages with respect to project 'Samples.NuGet\DemoApp\DemoApp', targeting '.NETFramework,Version=v4.5.2'
Attempting to resolve dependencies for multiple packages
Resolving actions install multiple packages
...
Package removal starts here...
...
Removed package 'Microsoft.AspNet.Web.Optimization 1.1.3' from 'packages.config'
Successfully uninstalled 'Microsoft.AspNet.Web.Optimization 1.1.3' from DemoApp
Removed package 'WebGrease 1.5.2' from 'packages.config'
Executing script file 'D:\Projects\DemoApp\packages\WebGrease.1.5.2\tools\uninstall.ps1'
Successfully uninstalled 'WebGrease 1.5.2' from DemoApp
...
More package removals here. Omitted for brevity...
...
Removed package 'Microsoft.Web.Infrastructure 1.0.0.0' from 'packages.config'
Successfully uninstalled 'Microsoft.Web.Infrastructure 1.0.0.0' from DemoApp
...
More package removals here. Omitted for brevity...
...
Removed package 'Antlr 3.4.1.9004' from 'packages.config'
Successfully uninstalled 'Antlr 3.4.1.9004' from MvcLenseApp
Package 'Antlr.3.4.1.9004' already exists in folder 'D:\Projects\Lense.Mvc5\packages'
--- Install packages (in reverse order) ---
Package 'Antlr.3.4.1.9004' already exists in folder 'D:\Projects\DemoApp\packages'
Added package 'Antlr.3.4.1.9004' to 'packages.config'
Successfully installed 'Antlr 3.4.1.9004' to DemoApp
...
More package installs here. Omitted for brevity...
...
Package 'Microsoft.Web.Infrastructure.1.0.0' already exists in folder 'D:\Projects\Lense.Mvc5\packages'
Added package 'Microsoft.Web.Infrastructure.1.0.0' to 'packages.config'
Successfully installed 'Microsoft.Web.Infrastructure 1.0.0' to MvcLenseApp
...
More package installs here. Omitted for brevity...
...
Package 'WebGrease.1.5.2' already exists in folder 'D:\Projects\DemoApp\packages'
Added package 'WebGrease.1.5.2' to 'packages.config'
Executing script file 'D:\Projects\DemoApp\packages\WebGrease.1.5.2\tools\install.ps1'
Successfully installed 'WebGrease 1.5.2' to DemoApp
Package 'Microsoft.AspNet.Web.Optimization.1.1.3' already exists in folder 'D:\Projects\DemoApp\packages'
Added package 'Microsoft.AspNet.Web.Optimization.1.1.3' to 'packages.config'
...
End of package re-install.
...
Successfully installed 'Microsoft.AspNet.Web.Optimization 1.1.3' to DemoApp
PM>
当然,如果您希望重新安装所有软件包,则可能需要在此处和此处的NuGet中熟悉更新/安装命令。