NuGet包未添加引用

3
我有一个自定义的NuGet包(My.Resources),其中包含一个程序集和对另一个自定义NuGet包(My.Base)的依赖。
如果我安装这个包,安装过程会顺利完成,但程序集引用并未被添加。以下是Install-Package命令的完整输出:
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)文件夹中。

1个回答

6
NuGet将您的NuGet软件包视为仅包含语言资源的本地化NuGet软件包。此类NuGet软件包中的程序集不会被引用。
如果将My.Resources.dll重命名为My.Resources2.dll等名称,则NuGet将引用该程序集。
基本上,任何以.resources.dll结尾的文件都被NuGet视为资源程序集,安装NuGet软件包时不会被引用。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接