未为 NuGet 包添加引用 [英] Reference not added for NuGet package

查看:57
本文介绍了未为 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 包添加引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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