在安装用于MVC的sitemapprovider时出现此错误:

Install-Package : Updating 'Microsoft.AspNet.Razor 3.2.2' to 'Microsoft.AspNet.Razor 2.0.20505.0' failed. Unable to find versions of
'Microsoft.AspNet.WebPages, Microsoft.AspNet.Mvc' that are compatible with 'Microsoft.AspNet.Razor 2.0.20505.0'.
At line:1 char:1
+ Install-Package MvcSiteMapProvider.MVC4
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

最佳答案

该错误表明您正在安装MvcSiteMapProvider.MVC4 NuGet package,但是您的项目是MVC 5(因为它具有Razor 3.2.2)。您必须将与您的MVC版本(在本例中为MvcSiteMapProvider.MVC5)匹配的软件包安装到项目中。

PM> Install-Package MvcSiteMapProvider.MVC5


请注意,MvcSiteMapProvider NuGet package已过时,除非打算使用MvcSiteMapProvider v3.x,否则不应将其安装到任何项目中。

如果要从MvcSiteMapProvider v3升级到v4,请参见upgrade guide

10-01 23:32