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)

roundcrisis
  • 17,276
  • 14
  • 60
  • 92
  • What's the full path for $NunitRunners? It looks like it is missing the `tools\lib` part so the paths to NUnit.Core.dll and NUnit.Core.Interfacesl.dll will be incorrect. – Matt Ward Jul 28 '14 at 08:53

2 Answers2

1

The paths to NUnit.Core.dll and NUnit.Core.Interfaces.dll are incorrect.

Currently $NunitRunners is pointing to packages\NUnit.Runners.2.6.3 when it should be pointing to packages\NUnit.Runners.2.6.3\tools\lib.

So you can either change the $NunitRunners path or add it later on when you add the references:

 $project.Object.References.Add($NunitRunners+"\tools\lib\nunit.core.dll")
 $project.Object.References.Add($NunitRunners+"\tools\lib\nunit.core.interfaces.dll")
Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • I m blind :D I also added some version info by iterating the package as in here https://github.com/techtalk/SpecFlow/blob/master/Installer/NuGetPackages/NUnit.Runners/Install.ps1 – roundcrisis Jul 28 '14 at 14:58
0

So you have tried specifying the NUnit.Runners 2.6.3 dependency in your nuspec file and it doesn't work? Have you tried specifying the NUnit core as a dependency as well?

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

If this doesn't work, you could also try including the NUnit dlls in the file section and include them in your package A, but that's not ideal.

What Would Be Cool
  • 6,204
  • 5
  • 45
  • 42
  • Hi. Thanks for the answer. I don't need a reference to NUnit on this package. I did add a dependency reference to NUnit.Runners as you have here. Install.ps1 is the recommended way to do crazy stuff like this and since this is for an OSS project I rather try the way it should be. Adding the dlls I need in the files section is not going to cut it. – roundcrisis Jul 27 '14 at 21:15