我有我的nuget包,我们称之为 A ,它依赖于另一个公共包 Nunit.Runners
当A依赖于Nunit.Runners时,它不会将我需要的程序集添加到项目中,我依赖的程序集位于 NUnit.Runners.2.6.3 \ tools \ lib 中,所以,因为nuget只在lib中添加了对程序集的引用,我想我需要在我的nuget包中添加一个Install.ps1
我现在有
param($installPath, $toolsPath, $package, $project)
$NunitRunners = join-path -path $packagesFolder -childpath "NUnit.Runners.2.6.3"
$project.Object.References.Add($NunitRunners+"\nunit.core")
$project.Object.References.Add($NunitRunners+"\nunit.core.interfaces")
但它正在抛出
Exception calling "Add" with "1" argument(s): "Unspecified error
(Exception from HRESULT: 0x80004005 (E_FAIL))" At
+ $project.Object.References.Add <<<< ($NunitRunners+"nunit.core.dll")
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
关于为什么这会引发“添加”超级欢迎
的任何指示我的install.ps1(此处仅供参考)
param($installPath, $toolsPath, $package, $project)
write-host "Install path" $installPath
$packagesFolder = Split-Path -Path $installPath -Parent
write-host "packages folder" $packagesFolder
write-host $toolsPath
write-host $package
$NunitRunners = join-path -path $packagesFolder -childpath "NUnit.Runners.2.6.3"
write-host $NunitRunners
$project.Object.References.Add($NunitRunners+"\nunit.core")
$project.Object.References.Add($NunitRunners+"\nunit.core.interfaces")
BTW我只需要引用那两个程序集,我不需要引用nunit.framework
注意:我确实在codeplex中看到this线程,但没有任何指向解决方案(即项目不是客户端配置文件,并且程序集不应该在GAC上)
答案 0 :(得分:1)
NUnit.Core.dll和NUnit.Core.Interfaces.dll的路径不正确。
目前 $ NunitRunners 指向packages\NUnit.Runners.2.6.3
,指向packages\NUnit.Runners.2.6.3\tools\lib
。
因此,您可以更改$ NunitRunners路径,也可以在以后添加引用时添加它:
$project.Object.References.Add($NunitRunners+"\tools\lib\nunit.core.dll")
$project.Object.References.Add($NunitRunners+"\tools\lib\nunit.core.interfaces.dll")
答案 1 :(得分:0)
因此,您已尝试在NUnit.Runners 2.6.3文件中指定nuspec依赖项,但它不起作用?您是否尝试将NUnit core指定为依赖项?
<dependencies>
<dependency id="NUnit" version="2.6.3" />
<dependency id="NUnit.Runners" version="2.6.3" />
</dependencies>
如果这不起作用,您也可以尝试在文件部分中包含NUnit dll并将它们包含在包A中,但这并不理想。