首页 > 解决方案 > C++ CLR NuGet 包错误:安装失败

问题描述

所以我正在使用 C++ 来处理一个项目,并且我创建了一个 GUI。我尝试使用 NuGet 来代替包但是,它不断出现此错误:

Could not install package 'MetroModernUI 1.4.0'. You are trying to install this package into a project that targets 'native,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

我在这里找到了一个链接来帮助我解决这个问题。但是,第 2 步出现了另一个问题。这是链接和错误:

如何使我的托管 NuGet 包支持 C++/CLI 项目?

Install failed. Rolling back...
Package 'NuGet.CommandLine.5.8.1' does not exist in project 'Project Name'
Package 'NuGet.CommandLine.5.8.1' does not exist in folder '<path>\packages'

该目录中甚至不存在 Package 文件夹。有人请帮助我,因为在尝试使用 NuGet 代替包时,上一个错误中也出现了该错误,这里是:

Install failed. Rolling back...
Package 'MetroModernUI.1.4.0' does not exist in project 'Project Name'
Package 'MetroModernUI.1.4.0' does not exist in folder '<path>\packages'

标签: .netvisual-studionugetclrnuget-package

解决方案


脚步

1首先,通过Nuget Package Manager UI将NuGet.CommandLine版本安装4.7.3到您​​的 clr 项目中。

2)之后,在新创建的packages.config文件下手动添加

<package id="MetroModernUI" version="1.4.0"/>

然后,重建您的项目以恢复 nuget 包MetroModernUI

您可以在下面找到nuget包安装到您的项目中<Solution_Folder>\packages\MetroModernUI.1.4.0.0

3)然后右键单击References --> Add Reference --> Browse然后添加

<Solution_Folder>\packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.dll或该文件夹中的任何其他人。

您应该注意 clr 项目无法通过 nuget 自动引用网络程序集 dll。您应该手动添加它们。

所有这些步骤都将帮助你得到你想要的。


推荐阅读