The "Exec" task needs a command to execute, the poor thing

on May 24th, 2007 at 11:57am , 87 responses

Here's a strange error message.

I was trying to build a project in VS2005, and got this instead of a successful build:


The "Exec" task needs a command to execute.


After pooling out a few hairs, I remembers that I recently have edited the pre-build actions for this project.

Looking this up, I found that I left a spare newline at the end of the pre-build script. So VS2005 sent msbuild an order to run an empty command.


Now I wonder, had the VS2005 guys have ever heard of StringSplitOptions.RemoveEmptyEntries?

They could've easily ignore empty lines, or better yet, issue a warning for that kinda stuff.

The Ron The Ron on June 5th, 2007 at 12:01pm
Nice... It saved me a couple hairs on the ole head.Damn stray NEWLINEs. ;-)
Omar Omar on June 21st, 2007 at 6:15pm
Thanks Man, I started to pull my hair as well, put that was a quick fix.
BUbba Ole BUbba Ole on June 27th, 2007 at 4:47pm
Someone needs to shake up things up there. Sounds like the evil QA folks again!Just googling and I found this. Thanks man!
Ken Egozi Ken Egozi on June 27th, 2007 at 6:19pm
supro cool.We have a saying in Hebrew, that when a problem of an individual becomes public domain, it becomes half-way into a comfort.Sorry to hear more people had that problem though, cuz it is of the really annoying kind.
Craig Craig on November 21st, 2007 at 2:13am
Awsome :) never would have found that issue.. thanks google and thanks to this forum.
Jack Jack on November 27th, 2007 at 4:07pm
OOPS! this is cute and great tips! It did exactly happen to me just now!Thanks for the sharing.
Jamie Jamie on December 5th, 2007 at 4:31pm
Cheers buddy, you just saved me destroying all my kernel logic trying to find that one!!!! thnxs
Ken Egozi Ken Egozi on December 6th, 2007 at 9:24am
Glad to have helped.Now be a dear and Kick it/digg it/Send Paypal/Use my amazon bookstore/whatever just don't have to.but I do know your IP, so I'd track you down if you won't.kidding, again.or am I?
Mahmoud Mahmoud on January 3rd, 2008 at 11:44am
that was great easy solution, I forgot that a new line in the pre-Build event was added when i edited the script code.
Jens Hofmann Jens Hofmann on February 13th, 2008 at 8:59am
Thanks a lot for this hint, had the same problem 1 minute ago. It's really bad that this issue still exists in VS 2008 :(
krish krish on February 14th, 2008 at 6:07pm
Gr8. Thanks for saving my thinning hair.
d d on March 6th, 2008 at 12:22pm
thanks a bunch saved me from going to the barber..hehehehe...thanks:)
Coderess Coderess on March 19th, 2008 at 6:01pm
You saved me quite a headache here... Can't believe this is still an issue in VS 2008
DA MAN DA MAN on March 19th, 2008 at 8:44pm
Thanks, it just happened to me in VS express!. Delete it the newline and my project built again. Cheers.
Prabin Varma Prabin Varma on April 10th, 2008 at 3:00pm
Thanks Ken. Saved me a lot of time.
Ayan Ayan on April 15th, 2008 at 2:13am
Anunay Anunay on May 13th, 2008 at 1:42am
Thanks dude ! This should be added to MSDN
Pastiche Pastiche on May 19th, 2008 at 2:56pm
Thanks! This was the first post I checked - problem solved in about 20 seconds!
sheriff sheriff on May 26th, 2008 at 9:46pm
got to thank you for that one, so thank you!
EWilan EWilan on June 10th, 2008 at 9:58pm
Nice find! Apparently, this also happens in post-build events in VS2008.
Arthur Arthur on June 12th, 2008 at 2:52am
More hair saved today! ;-) Thanks!
dragosh dragosh on June 17th, 2008 at 11:38am
You save my day!!!Thanks
Rahul Shukla Rahul Shukla on June 23rd, 2008 at 9:04am
Thanks a ton dude ... u saved my lot of time :)
Amir Simantov Amir Simantov on August 21st, 2008 at 8:13am
Ken the Canon!
Ken Egozi Ken Egozi on August 21st, 2008 at 5:48pm
@Amir - now that's a first ... :)
Nicky Nicky on September 26th, 2008 at 10:57am
Cheers for this. Got this solved this in 30 seconds thanks to your post.
Simon Simon on November 6th, 2008 at 10:38am
Thanks for not keeping such a great discovery to yourself. Saved a lot of time and pain.
Ramin Tarhandeh Ramin Tarhandeh on November 15th, 2008 at 8:08am
Thanks a lotit saved me the few hours
richard richard on November 17th, 2008 at 1:35pm
sathish sathish on November 22nd, 2008 at 4:06am
thanks a lot..saved hell of time..
Dave Dave on December 5th, 2008 at 1:46pm
Thank you!
Rod Rod on December 12th, 2008 at 12:00am
THANKS! Saved me a ton of time. Never would have thought to look there until I was bald!
Sandip Pradhan Sandip Pradhan on December 17th, 2008 at 3:59am
Thanks, I could fix it in 10 seconds.
Ethan Ethan on December 17th, 2008 at 8:01pm
This helped me too, thanks!
John John on December 19th, 2008 at 7:13pm
You just saved me from a world of hurt! Thank you!
praveen hooda praveen hooda on December 24th, 2008 at 10:24am
Thanks a lot dude it saved a lot of time and frustration.
Phil Shelton Phil Shelton on January 10th, 2009 at 8:55pm
Thanks - it was late and I never noticed that spare line!
Dmitry Dmitry on January 11th, 2009 at 1:29pm
Heh, till now( VS 2008 SP1) still not fixed )
cox cox on February 1st, 2009 at 5:26pm
Elad Elad on February 19th, 2009 at 10:51am
Thanks! you sure did saved me a lot of time
Pedro Pedro on February 20th, 2009 at 12:21pm
what a stupid bug...Thanks.
Xie Xie on February 20th, 2009 at 9:28pm
Gabi Gabi on February 25th, 2009 at 5:49pm
I left a space line in Post-build. It's fixed after clean empty lines. Great Thanks!
Kofi A Kofi A on March 2nd, 2009 at 1:32pm
Saved a few hairs too. Thanks man...
Mohan Mohan on March 18th, 2009 at 7:15pm
Thanks buddy
Ken Egozi Ken Egozi on March 19th, 2009 at 5:51am
@Nicky, @Simon, @Ramin, @richard, @sathish, @Dave, @Rod, @Sandip, @Ethan, @John, @praveen, @Phil, @Dmitry, @cox, @Elad, @Pedro, @Xie, @Gabi, @Kofi, @Mohan (did I miss anyone?) := you're more than welcome :)
Mark Woodlief Mark Woodlief on March 23rd, 2009 at 1:35pm
Thanks!!!!!! Was going nuts on this till I found your post!!!
JRS JRS on March 26th, 2009 at 5:17pm saved me a lot of time with this post. I was going bonkers on this one!!!!!
Jason Jakob Jason Jakob on April 1st, 2009 at 2:40pm
I accidently clicked the "Sign" icon just under the File menu in VS2005 and quickly clicked "Unsign" again to fix. This left a Post build new line. broke compilation. Thanks a bundle!
Vid Vid on April 6th, 2009 at 9:50pm
Thanks,This helped me too!
m42 m42 on April 25th, 2009 at 7:48am
big problem easy soluitionThanks!
Amin Sayed Amin Sayed on June 24th, 2009 at 4:48am
Really good one... thanks man!!!
Neelima Dommeti Neelima Dommeti on July 15th, 2009 at 3:43am
Thanks a Lot!!
juan agui juan agui on July 16th, 2009 at 3:04am
miro miro on July 20th, 2009 at 6:36am
Thank you , I spare my hairs :-)
Praveena Praveena on July 31st, 2009 at 8:29am
Thanks u saved my Job.. :)
Faisal Raza Faisal Raza on August 5th, 2009 at 4:37am
gear post and great solution, :D
Alan Yost Alan Yost on August 18th, 2009 at 10:19am
Yep - saved me. Thanks google - and thanks for your contribution!Cheers.
danteprax danteprax on September 16th, 2009 at 6:11pm
Very useful, only the experience gives it knowledge.....Thks a lot.
Don Don on September 23rd, 2009 at 10:48am
Tons of thanks to you!!! You saved my valuable time to quick fix it.
haider haider on October 20th, 2009 at 5:09pm
yes you saved my hairs too :)
Stan Stan on October 22nd, 2009 at 6:18pm
The "Exec" task needs a command to execute, the poor thing-- now that's funny
Thao Thao on November 16th, 2009 at 5:51pm
Same here, thanks for the tip! I suspected it was the editing I did on the post-build event but didn't think it was because of the blank spaces after I deleted all the text! Removing it fixed it!
Joyce Joyce on November 19th, 2009 at 4:01pm
thanks for the tip...i was starting to freak, but you saved me :)
Jon Jon on November 25th, 2009 at 6:50am
Saved me a lot of time, great post!
Renu Renu on December 1st, 2009 at 5:55am
Thank you. You saved my time.
Pedro Dias Pedro Dias on December 9th, 2009 at 4:58pm
Thanks a lot
Kevin Kevin on December 25th, 2009 at 10:08pm
Nothing improved in vs 2008. I run into the same problem today but managed to found this. Thanks, Man. Good work.
Fahad Shaikh Fahad Shaikh on January 20th, 2010 at 3:08am
Thanks buddy. It saved me a lot of trouble. Things like this should be posted and shared. Thanks a lot.
Praveen Praveen on February 13th, 2010 at 4:53am
Thanks a lot Ken. Saved lotta time for me :)
Richie Richie on February 19th, 2010 at 10:54am
Another thank you! Problem solved.
James James on March 3rd, 2010 at 5:52pm
Saved me, too! Thank you for posting this!
THANKS THANKS on April 3rd, 2010 at 12:49pm
amazing post. you saved me hours of debugging.from reading all the comments, shall we call you: The Savior? :D
Chris Chris on April 27th, 2010 at 1:02pm
You really made my day! Thanx
Developer Developer on May 20th, 2010 at 9:00pm
Thanks....Really Really helpful...This needs to be posted on MSDN
Orlit Tanenbaumowitz Orlit Tanenbaumowitz on May 16th, 2010 at 9:00pm
Can you believe that this is still in VS2010?Amazing.Thanks.
Geoff Geoff on May 13th, 2010 at 9:00pm
Thanks! Saved me a lot of grief. Had this happen to me in the VS2008 Post-build event after clicking on Sign and then Unsign after remembering that I didn't need to sign after all.
on April 8th, 2011 at 7:49am

Thankyou It saved me a lot of time

Kevin Kevin on April 20th, 2011 at 1:53pm

Thanks for the info - I ran into the same problem as everyone else.

David Glaubman David Glaubman on June 4th, 2011 at 12:57am

Thanks, as well. This still lives in VS2010 SP1!

David Muscat David Muscat on September 9th, 2011 at 2:08am

Thanks...saved me some time

Ashish Ashish on September 15th, 2011 at 6:53am

Thanks so much really saved me a lot of time....:)

kannan kannan on September 26th, 2011 at 5:31pm

Thanks a lot ! I got this error, searched in google, stumbled on to this page, FIXED !

Jon  Swoveland Jon Swoveland on May 25th, 2012 at 9:29pm

Yeah-you!!! Boooo MS!!! Got this in VS 2010...still not fixed!!!

shiran shiran on August 8th, 2012 at 5:52am

thank you! it helped me out!!

El Smurfa Diablo El Smurfa Diablo on April 26th, 2013 at 2:36pm

good catch...still applies! thanks, esd

marc marc on June 5th, 2013 at 1:39pm

Thank you sooo much for sharing. Same issue in visual studio 2010 !

Comment preview:



Posts count: