尽管答案数量很多,但我会添加另一个答案,恕我直言,这会让事情变得更清楚。
正如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 中的更新/安装命令。