【发布时间】:2013-05-31 11:29:23
【问题描述】:
在确定应将包中的哪些 dll 作为程序集引用添加时,NuGet 会排除以“.Resources.dll”结尾的任何内容。这旨在排除本地化的satellite assemblies,但这意味着如果您有一个名为 MyCompany.Resources.dll 的 DLL,则添加引用会很棘手。
有什么好的解决方法吗?
【问题讨论】:
标签: nuget
在确定应将包中的哪些 dll 作为程序集引用添加时,NuGet 会排除以“.Resources.dll”结尾的任何内容。这旨在排除本地化的satellite assemblies,但这意味着如果您有一个名为 MyCompany.Resources.dll 的 DLL,则添加引用会很棘手。
有什么好的解决方法吗?
【问题讨论】:
标签: nuget
我现在按照https://nuget.codeplex.com/workitem/1644 的示例解决了这个问题,并进行了一些修改。
我为网站项目添加了检查,因为它们不支持“添加”方法。
我在 nuspec 文件中的 metadata 元素之后添加了这个。 (可能只有在您使用 NuGet 2.5 中提供的 includereferencedprojects 选项时才需要)
<files>
<file src="bin\Release\Foo.Resources.dll" target="lib\net40" />
<file src="bin\Release\Foo.Resources.pdb" target="lib\net40" />
<file src="tools\*" target="tools" />
</files>
然后将这两个文件添加到我的项目目录中的新 tools 文件夹中。 (注意 DLL 路径传递给 References.Add 方法的方式的修复,与 codeplex 示例相比)
Install.ps1
param($installPath, $toolsPath, $package, $project)
$resourcesDll = Join-Path $installPath "lib\net40\Foo.Resources.dll"
Write-Host "Adding resources DLL from " $resourcesDll
if ($project.Kind -eq "{E24C65DC-7377-472b-9ABA-BC803B73C61A}") {
$project.Object.References.AddFromFile($resourcesDll)
} else {
$project.Object.References.Add($resourcesDll)
}
Uninstall.ps1
param($installPath, $toolsPath, $package, $project)
Write-Host "Removing Foo.Resources reference"
$project.Object.References | where { $_.Name -eq 'Foo.Resources' } | foreach { $_.Remove() }
【讨论】:
NuGet 的这个分支有一些改变可以解决这个问题,但是考虑到额外的复杂性,我不确定它是否会成为 master:https://nuget.codeplex.com/SourceControl/network/forks/jjgonzalez/1644/contribution/5459
【讨论】: