MsBuild Error MSB5009

In our rapid deployment strategy, we use msbuild.exe to build our .net solution files from the command line, which helps us build solutions without Visual Studio on our servers.  This has worked flawlessly for over a year now, but recently (after refactoring our solution file for efficiency) we got the infamous “Solution file error MSB5009: Error parsing the nested project section in solution file” message from msbuild.

Initially, I was stumped becasue the solution opened fine in Visual Studio – so I had no idea why VS2005 could build the solution, but msbuild could not.

After some Googling, I found this MSDN forum post, which outlined the same problem.  The solution, as outlined on the last post was supprisingly simple.

  1. In Visual Studio, add a new file to the solution (not the project), something like a text file.
  2. Save all.
  3. Remove the new file.
  4. Save all.

After I had done this, I commited the change, and tried again – and it worked great.  Obviously there was some old project references which was screwing up the works.  It now works fine and I am a happy panda once again.