1

I am trying to run a batch file on post-build event but I am failing. the following is my text which I have put my post-build event;

E:\Documents\Tools\minify-css-files.bat

And I am getting this;

Error 46 The command "E:\Documents\Tools\minify-css-files.bat" exited with code 9009.

When I run the batch file outside the VS, it is ok. Here is my batch file.

AjaxMin ..\Content\site.css -out ..\Content\site.ajaxmin.css –clobber
AjaxMin ..\Content\search-engine.css -out ..\Content\search-engine.ajaxmin.css –clobber
AjaxMin ..\Content\print.css -out ..\Content\print.ajaxmin.css –clobber
AjaxMin ..\Content\site.easyslider.css -out ..\Content\site.easyslider.ajaxmin.css –clobber
abatishchev
  • 95,331
  • 80
  • 293
  • 426
tugberk
  • 56,001
  • 60
  • 237
  • 326
  • 1
    According to http://stackoverflow.com/questions/1351830/exited-with-code-9009 this will happen if you're trying to access a path with spaces. I'm assuming inside the batch file there is a problem. – ta.speot.is Jun 25 '11 at 08:12
  • or http://social.msdn.microsoft.com/forums/en-US/windowsgeneraldevelopmentissues/thread/42f3fa84-87a6-4eed-aeb9-143316af2013/ – Mark Huk Jun 25 '11 at 08:21

2 Answers2

2

Anyway, always escape spaces in all paths used, e.g. ... "$(ProjectDir)" ...

abatishchev
  • 95,331
  • 80
  • 293
  • 426
1

You'll have to use the Visual Studio post-build macros in order to get the full path to your project files.

Here's an example:

AjaxMin "$(ProjectDir)Content\site.css" -out "$(ProjectDir)Content\site.ajaxmin.css" –clobber

The $(ProjectDir) macro will be translated to the full path of the project directory, including the trailing backslash.

Note that the macros are expanded by Visual Studio during a build process, which means that your batch file will no longer work when invoked outside of that context.

Related resources:

Enrico Campidoglio
  • 52,458
  • 11
  • 119
  • 149