当确定应该将包中的哪些dll添加为程序集引用时,NuGet会排除任何结束".Resources.dll"的内容.这旨在排除本地化的附属程序集,但是如果您有一个名为MyCompany.Resources.dll的DLL,则意味着添加引用很棘手.
这有什么好的解决方法吗?
我现在通过https://nuget.codeplex.com/workitem/1644上的示例进行了一些修改,从而解决了这个问题.
我添加了对网站项目的检查,因为它们不支持"添加"方法.
我metadata在nuspec文件中的元素之后添加了这个.(如果你没有使用includereferencedprojectsNuGet 2.5中提供的选项,可能只有必要)
<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>
Run Code Online (Sandbox Code Playgroud)
然后将这两个文件添加到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)
}
Run Code Online (Sandbox Code Playgroud)
Uninstall.ps1
param($installPath, $toolsPath, $package, $project)
Write-Host "Removing Foo.Resources reference"
$project.Object.References | where { $_.Name -eq 'Foo.Resources' } | foreach { $_.Remove() }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1780 次 |
| 最近记录: |