0

I have my nuget package, lets call it A that has a dependency on another public package Nunit.Runners

When A depends on Nunit.Runners it doesn't add the assemblies I need into my project, the assemblies I depend on are in NUnit.Runners.2.6.3\tools\lib so, because nuget only adds referces to assemblies in lib, I think I need to add a Install.ps1 to my nuget package

I now have

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")

But it's throwing

 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

Any pointers as to why this is throwing on "Add" super welcome

My install.ps1 (here for reference)

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 I just need to reference those two assemblies, I don't need to reference nunit.framework

NOTE: I did see this thread in codeplex but nothing there pointed to a solution (ie the project is not client profile and the assemblies shouldn't be on the GAC)

4

2 回答 2

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")
于 2014-07-28T08:58:01.283 回答
0

因此,您尝试在nuspec文件中指定NUnit.Runners 2.6.3依赖项,但它不起作用?您是否也尝试过将NUnit 核心指定为依赖项?

<dependencies>
  <dependency id="NUnit" version="2.6.3" />
  <dependency id="NUnit.Runners" version="2.6.3" />
</dependencies>

如果这不起作用,您也可以尝试在文件部分中包含 NUnit dll 并将它们包含在您的包 A 中,但这并不理想。

于 2014-07-27T20:55:07.600 回答