Reputation: 53331
Traditionally, nunit-console.exe
has been included in the repository and on the build server (or any other machine) this EXE was called from some build script.
Now that the NUnit.Runners package is available I wonder how this could be used from a psake build script. It is a solution-level package so it doesn't leave any trace in packages.config
and cannot be auto-restored as other project-level packages so I guess one would need to call Install-Package
from the psake script, wait for the download and then execute the unit tests? Hopefully this download can be run only once and it will not slow down the build every time it runs. Or will it?
Upvotes: 14
Views: 4360
Reputation: 22310
I have created an issue with nuget developers, and proposed a fix.
Modify the nuget.targets file with the following changes:
In <PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
add this element:
<SolutionLevelPackagesConfig>$([System.IO.Path]::Combine($(SolutionDir), ".nuget\packages.config"))</SolutionLevelPackagesConfig>
In <PropertyGroup>
add this element:
<RestoreSolutionLevelCommand>$(NuGetCommand) install "$(SolutionLevelPackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir) "</RestoreSolutionLevelCommand>
In <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
add this element before the RestoreCommand for WinNT:
<Exec Command="$(RestoreSolutionLevelCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)') And Exists('$(SolutionLevelPackagesConfig)')" />
This made my msbuild to restore the solution level packages.
Upvotes: 2
Reputation: 8018
Just ran into this myself. Quite easy to fix as follows:
From now on, when you build, Nuget will pull down the Nunit.Runners packages if it is not on the machine. I then reference the Nunit runner from the package in my command line build.
I have this working in a little project I did for a TeamCity build light on Github. Packages.config in the unit test project has been modified as discussed above. You can look at the MSBuild file to see how I run tests from the command line. (build.proj, which references some targets and properties contained in the repository's tools\msbuild folder). You will need the latest Nuget Package Manager installed before you try to build in VS.NET or from the command line (clicktobuild.bat).
You should be able to port the idea of how to run Nunit console from the right location into psake quite easily.
Upvotes: 8
Reputation: 1436
This doesn't answer your question, but may be of use to someone facing a similar problem. I ran into the same problem trying to set up a TeamCity build. I worked around this by reverting to an older version of nunit.
NUnit 2.5.10.11092 still has the nunit exe's in the nuget package.
Upvotes: 0