简体   繁体   English

Nuget 无法安装 package "RazorGenerator.Mvc" 与特定版本 2.3.12

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

I had this error while trying to install Nuget package "RazorGenerator.Mvc" with the specific version 2.3.12 using this command:尝试使用以下命令安装具有特定版本 2.3.12 的 Nuget package "RazorGenerator.Mvc" 时出现此错误:

Install-Package RazorGenerator.Mvc -Version 2.3.12

However, when running the command, Visual Studio returned this error:但是,在运行该命令时,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'.

My project already has the package "Microsoft.AspNet.Mvc" installed with the latest version, I have also tried installing this package with version 3.0.50813.1 but both attempts didn't resolve the error.我的项目已经安装了最新版本的 package“Microsoft.AspNet.Mvc”,我也尝试安装版本为 3.0.50813.1 的 package,但两次尝试都没有解决错误。 Do you guys have any idea how to fix this issue?你们知道如何解决这个问题吗? The specific version of the package "RazorGenerator.Mvc" has to be 2.3.12 . package "RazorGenerator.Mvc" 的特定版本必须是2.3.12

You can try any of these 3 things:您可以尝试以下 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" ie 2.3.12 (RazorGenerator.Mvc will install all the dependencies)从 Nuget 包管理器中,从您的项目中卸载包“Microsoft.AspNet.Mvc”,然后尝试安装包“RazorGenerator.Mvc”的特定版本,即 2.3.12(RazorGenerator.Mvc 将安装所有依赖项)

  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.简而言之,检查您的项目是否需要 .Net Framework 或 .NetCore 以安装此 nuget 包。

  3. Remove any dlls,exe from bin/ debug folder and try installing the nuget again.从 bin/debug 文件夹中删除任何 dll、exe 并尝试再次安装 nuget。

For anyone wondering, I have resolved this error.对于任何想知道的人,我已经解决了这个错误。 Somehow I couldn't use Nuget package manager to install "RazorGenerator.Mvc" to the correct version "2.3.12" - the installed RazorGenerator package was of a different version, I couldn't uninstall it nor update to 2.3.12 because of dependencies from other packages. Somehow I couldn't use Nuget package manager to install "RazorGenerator.Mvc" to the correct version "2.3.12" - the installed RazorGenerator package was of a different version, I couldn't uninstall it nor update to 2.3.12 because of来自其他包的依赖项。 However, I have resolved the issue by updating this line in "packages.config" and rebuild the solution.但是,我通过更新“packages.config”中的这一行并重建解决方案来解决了这个问题。

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

After this, the version of "RazorGenerator.Mvc.dll" in my bin folder, and the version in Nuget was "2.3.12".在此之后,我的 bin 文件夹中的“RazorGenerator.Mvc.dll”版本和 Nuget 中的版本为“2.3.12”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM