无法在 .NET Framework 4.7.2 项目中安装 Nuget 包 [英] Unable to install a Nuget Package in a .NET Framework 4.7.2 project

查看:158
本文介绍了无法在 .NET Framework 4.7.2 项目中安装 Nuget 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VS2017 中使用 .NET Framework 4.7.2WPF 项目中,我正在尝试安装 Interop.MSUtil.dll 建议的 NuGet 包 此处.我确实需要安装这个包,所以有人可以帮我安装它或提供解决方法.

错误:

<块引用><块引用>

安装包:无法安装包Interop.MSUtil.dll 1.0.0".您正在尝试将此包安装到以.NETFramework,Version=v4.7.2"为目标的项目中,但该包不包含任何与该框架兼容的程序集引用或内容文件.有关更多信息,请联系软件包作者.在行:1 字符:1+ 安装包 Interop.MSUtil.dll -版本 1.0.0+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception+ FullQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

解决方案

Interop.MSUtil.dll 的 NuGet 包似乎与 .NET 4.7.2 Framework 不兼容.>

但是,如果您的机器上安装了 LogParser 并且您具有管理员访问权限,则可以在本地重新创建它.

  1. 找到您的 LogParser 副本.最有可能的位置在 C:\Program Files (x86)\Log Parser 2.2.

  2. 找到您的开发人员命令提示符.在 Windows 10 中,只需在 Windows 搜索栏中键入 developer command prompt.

  3. 以管理员身份运行.通常,这可以通过右键单击上下文菜单的开发人员命令提示符项来完成.

  4. cd 到 LogParser 的安装位置.

  5. 运行以下命令:

    tlbimp LogParser.dll/out:Interop.MSUtil.dll

这应该构建一个新版本的 Interop.MSUtil.dll,它将对您的框架版本友好.

现在您可以通过浏览到 LogParser 目录并选择新的 DLL 来手动添加它作为参考.

不要忘记您可能需要将 Embed Interop Types 设置为 False.

请注意,这很大程度上借鉴了之前的答案.

In my WPF project using .NET Framework 4.7.2 in VS2017, I'm trying to install Interop.MSUtil.dll NuGet package as suggested here. I do need this package installed, so could someone please help me installing it or providing a workaround.

Error:

Install-Package : Could not install package 'Interop.MSUtil.dll 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2', 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. At line:1 char:1 + Install-Package Interop.MSUtil.dll -Version 1.0.0 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], Exception + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

解决方案

It appears that the NuGet package for Interop.MSUtil.dll is not compatible with the .NET 4.7.2 Framework.

However, if you have LogParser installed on your machine and you have administrator access, you can recreate it locally.

  1. Locate your copy of LogParser. The most likely place is in C:\Program Files (x86)\Log Parser 2.2.

  2. Locate your Developer Command Prompt. In Windows 10, just type developer command prompt into the Windows search bar.

  3. Run it as Administrator. Generally this can be done by right-clicking on the Developer Command Prompt item for the context menu.

  4. cd to the location where LogParser is installed.

  5. Run the following command:

    tlbimp LogParser.dll /out:Interop.MSUtil.dll

This should build a new version of Interop.MSUtil.dll which will be friendly to your version of the Framework.

Now you can add it as a reference manually by browsing to the LogParser directory and selecting the new DLL.

Don't forget you may need to set Embed Interop Types to False.

Note that this draws heavily from this previous answer.

这篇关于无法在 .NET Framework 4.7.2 项目中安装 Nuget 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆