首页 > 解决方案 > Nuget 无法安装特定版本 2.3.12 的包“RazorGenerator.Mvc”

问题描述

尝试使用以下命令安装具有特定版本 2.3.12 的 Nuget 包“RazorGenerator.Mvc”时出现此错误:

Install-Package RazorGenerator.Mvc -Version 2.3.12

但是,在运行该命令时,Visual Studio 会返回此错误:

Failed to add reference. The package 'RazorGenerator.Mvc' tried to add a framework reference to 'System.Web.Mvc' which was not found in the GAC. This is possibly a bug in the package. Please contact the package owners for assistance. Cannot find assembly 'System.Web.Mvc'.

我的项目已经安装了最新版本的包“Microsoft.AspNet.Mvc”,我也尝试使用版本 3.0.50813.1 安装这个包,但两次尝试都没有解决错误。你们知道如何解决这个问题吗?包“RazorGenerator.Mvc”的特定版本必须是2.3.12

标签: c#asp.net-mvcnuget

解决方案


您可以尝试以下 3 种方法中的任何一种:

  1. 从 Nuget 包管理器中,从您的项目中卸载包“Microsoft.AspNet.Mvc”,然后尝试安装包“RazorGenerator.Mvc”的特定版本,即 2.3.12(RazorGenerator.Mvc 将安装所有依赖项)

  2. 交叉检查是否不是您的项目目标框架导致此问题。简而言之,检查您的项目是否需要使用 .Net Framework 或 .NetCore 才能安装此 nuget 包。

  3. 从 bin/debug 文件夹中删除所有 dll、exe 并尝试再次安装 nuget。


推荐阅读