Skip to content

Instantly share code, notes, and snippets.

@joshuaflanagan
Created June 24, 2011 03:19
Show Gist options
  • Save joshuaflanagan/1044159 to your computer and use it in GitHub Desktop.
Save joshuaflanagan/1044159 to your computer and use it in GitHub Desktop.
Example batch file to execute a tool from a Nuget package
@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
# 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
@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