Pregunta

I'm trying to run a pre-build event which passes all the JavaScript files in a directory to MS's Ajax Minifier. Unfortunately, this tool excepts file names as individual arguments (it cannot parse "*.js"). I have quite a few JavaScript files and I really don't want to list them individually in the pre-build event window.

This is my current pre-build command:

"$(SolutionDir)Tools\AjaxMin.exe" "$(ProjectDir)*.js" -out  "$(ProjectDir)Generated\Generated.js" -clobber

Does anyone know the proper syntax (or if there even is one) to make this do what you'd expect it to do?

Thanks for any assistance.

¿Fue útil?

Solución

Prebuild event is passed to shell that is why you can set a cmd-script like below as a pre-build event:

::Force variables to be evaluated at execution time
SETLOCAL ENABLEDELAYEDEXPANSION

SET parameter=
SET proj=$(ProjectDir)*.js

::Concatenate all the file names (surrounded by quotes) into a single string
FOR %%F IN ("%proj%") DO (SET parameter=!parameter! "%%F")

::Execute command
"$(SolutionDir)Tools\AjaxMin.exe" %parameter% -out  "$(ProjectDir)Generated\Generated.js" -clobber

Here we are accumulating all js filenames in parameter variable and passing it to ajaxmin.exe.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top