未为 NuGet 包添加引用

编程入门 行业动态 更新时间:2024-10-25 10:24:33
本文介绍了未为 NuGet 包添加引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个自定义 NuGet 包 (My.Resources),其中包含一个程序集和对另一个自定义 NuGet 包 (My.Base) 的依赖.

I've a custom NuGet package (My.Resources) containing an assembly and a dependency on another custom NuGet package (My.Base).

如果我安装包,安装成功完成,但没有添加程序集引用.以下是 Install-Package 命令的完整输出:

If I install the package, the installation finishes successfully, but the assembly reference is not added. Here is the full output from a Install-Packagecommand:

Attempting to resolve dependency 'My.Base (≥ 1.0.0)'. Installing 'My.Base 1.0.0'. Added file 'My.Base.dll' to folder 'My.Base.1.0.0\lib\net45'. Added file 'My.Base.1.0.0.nupkg' to folder 'My.Base.1.0.0'. Successfully installed 'My.Base 1.0.0'. Installing 'My.Rsources 1.1.0-beta0001'. Added file 'My.Resources.dll' to folder 'My.Resources.1.1.0-beta0001\lib\net45'. Added file 'My.Resources.XML' to folder 'My.Resources.1.1.0-beta0001\lib\net45'. Added file 'My.Resources.1.1.0-beta0001.nupkg' to folder 'My.Resources.1.1.0-beta0001'. Successfully installed 'My.Resources 1.1.0-beta0001'. Adding 'My.Base 1.0.0' to WindowsFormsApplication8. For adding package 'My.Base 1.0.0' to project 'WindowsFormsApplication8' that targets 'net45', >> Assembly references are being added from 'lib\net45' Added reference 'My.Base' to project 'WindowsFormsApplication8' Added file 'packages.config'. Added file 'packages.config' to project 'WindowsFormsApplication8' Successfully added 'My.Base 1.0.0' to WindowsFormsApplication8. Adding 'My.Resources 1.1.0-beta0001' to WindowsFormsApplication8. Added file 'packages.config'. Successfully added 'My.Resources 1.1.0-beta0001' to WindowsFormsApplication8.

虽然我们有其他几个自定义 NuGet 包的结构和构建方式相同,但这是唯一具有此行为的包..nupkg 中的 .nuspec 看起来不错,并且程序集位于正确的 (net45) 文件夹中.

While we have several other custom NuGet Packages structured and build the same way, this is the only one with this behavior. The .nuspec inside the .nupkg looks fine and the assembly is in the correct (net45) folder.

推荐答案

NuGet 将您的 NuGet 包视为 本地化的 NuGet 包,只包含语言资源.未引用此类 NuGet 包中的程序集.

NuGet is treating your NuGet package as a localized NuGet package that only contains language resources. Assemblies in this sort of NuGet package are not referenced.

例如,如果您将 My.Resources.dll 重命名为 My.Resources2.dll 之类的名称,则 NuGet 将引用该程序集.

If you rename your My.Resources.dll to something like My.Resources2.dll, for example, then NuGet will reference the assembly.

基本上任何以 .resources.dll 结尾的文件都被 NuGet 视为资源程序集,在安装 NuGet 包时不会被引用.

Basically any file that ends with .resources.dll is considered by NuGet to be a resource assembly will not be referenced when the NuGet package is installed.

更多推荐

未为 NuGet 包添加引用

本文发布于:2023-11-10 09:57:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575067.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:NuGet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!