Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Example batch file to execute a tool from a Nuget package

View nuget_tool.bat
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
@ECHO OFF
SETLOCAL
REM This can be used for any .exe installed by a nuget package
REM Example usage: nuget_tool.bat nunit-console.exe myproject.tests.dll
SET TOOL=%1
FOR /R %~dp0\source\packages %%G IN (%TOOL%) DO (
IF EXIST %%G (
SET TOOLPATH=%%G
GOTO FOUND
)
)
IF '%TOOLPATH%'=='' GOTO NOTFOUND
 
:FOUND
%TOOLPATH% %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
 
:NOTFOUND
ECHO %TOOL% not found.
EXIT /B 1
View nuget_tool.bat
1 2 3 4 5
# Usage: nunit_path = tool "NUnit", "nunit-console.exe"
 
def tool(package, tool)
File.join(Dir.glob(File.join(package_root,"#{package}.*")).sort.last, "tools", tool)
end
View nuget_tool.bat
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
@ECHO OFF
SETLOCAL
REM You might prefer specific scripts for each tool. Makes the usage a bit easier. This is an example for NUnit.
 
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.