I have nuget package with command line tools that I want to invoke from pre-build event in VS2015 project.
I could use relative path to invoke command from package folder but then I have to modify that path if either nuget package version or package folder changes. Is there an easier way to do this?
You could create a batch file in your project root to call your tools, which is similar with below script. More detailed information about use a tool installed by Nuget in your build scripts, please refer to:
@ECHO OFF
SETLOCAL
FOR /R %~dp0\source\packages %%G IN (nunit-console.exe) DO (
IF EXIST %%G (
SET TOOLPATH=%%G
GOTO FOUND
)
)
IF '%TOOLPATH%'=='' GOTO NOTFOUND
:FOUND
%TOOLPATH% %*
GOTO :EOF
:NOTFOUND
ECHO nunit-console not found.
EXIT /B 1