Nuget 无法安装特定版本 2.3.12 的包 "RazorGenerator.Mvc"

Nuget Failed to install package "RazorGenerator.Mvc" with specific version 2.3.12

我在尝试使用此命令安装具有特定版本 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.

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

  1. From Nuget package manager, Uninstall the package "Microsoft.AspNet.Mvc" from your project and then try installing the specific version of the package "RazorGenerator.Mvc" i.e. 2.3.12 (RazorGenerator.Mvc will install all the dependencies)

  2. Cross check whether it is not your target framework of the project that is causing this issue. In short, check whether you need your project with .Net Framework or .NetCore in order to install this nuget package.

  3. Remove any dlls,exe from bin/ debug folder and try installing the nuget again.

对于任何想知道的人,我已经解决了这个错误。不知何故,我无法使用 Nuget 包管理器将“RazorGenerator.Mvc”安装到正确的版本“2.3.12”——安装的 RazorGenerator 包是不同的版本,我无法卸载它,也无法更新到 2.3.12因为来自其他包的依赖性。但是,我已通过将此行更新为来解决问题 “packages.config”并重建解决方案。

<package id="RazorGenerator.Mvc" version="2.3.12" targetFramework="net48" />

之后,我的bin文件夹中的“RazorGenerator.Mvc.dll”版本,Nuget中的版本为“2.3.12”。