I am building a Selenium/Specflow project in Jenkins and would like to get the currently installed version of the NUnit Console Runner package via the Nuget.exe CLI.
I have to reference the NUnit Console Runner package folder path in my Jenkins build to run the NUnit tests. The folder name has the version in it and instead of having some hard coded path that is changing as the version changes I wanted to get the current version of the package and use that to build the path dynamically.
I have read through many questions explaining how to get the version in Powershell and in the Visual Studio client but I haven't seen a solution anywhere explaining how to get this information using nuget.exe. The rest of my Jenkins build is using nuget.exe and I have that auto-updating so I wanted to use that if possible.
I have tried using the List command but that doesn't reference Local because Local isn't a registered source.
C:\Program Files\nuget>nuget list nunit -source local
The specified source 'local' is invalid. Please provide a valid source.
If I run it with the active source I get everything in the remote Nuget repository with nunit in the title which isn't what I want.
***********EDIT***********
I am able to get the package by putting in the folder the packages are installed in as the source
nuget list nunit.ConsoleRunner -source C:\Jenkins\workspace\packages\
NUnit.ConsoleRunner 3.10.0
I wrote the below script to capture it and use it in the path to the Nuget package
setlocal enabledelayedexpansion
cd "c:\program files\nuget\"
for /f "tokens=2" %%a in ('nuget.exe list nunit.ConsoleRunner -source
C:/Jenkins/workspace/Project/packages/') do set versionString=%%a
echo !versionString!'
set pathToConsoleRunner="C:/Jenkins/workspace/Project/packages/NUnit.ConsoleRunner.!versionString!/tools/nunit3-console.exe"
echo !pathToConsoleRunner!'
!pathToConsoleRunner! C:/Jenkins/workspace/Project/bin/Debug/test.dll --where "cat == testCategory"
C:/Jenkins/workspace/Project/packages/ - Wherever your build is restoring your packages to C:/Jenkins/workspace/Project/bin/Debug/test.dll - The path to the DLL that contains your NUnit tests