Solution file warning MSB4051 GUID was not found in the .SLN file

We’re using CruiseControl.NET with an MSBuild task to build the solution file for a large ERP system which includes 21 .csproj files and recently when some code was moved to a new project the build started failing with this error:

Velocity.sln : Solution file warning MSB4051: Project {958E0376-0272-4149-A1CF-E03521D12A72} 
is referencing a project with GUID {14F4138C-4DA7-4029-A8D3-B1B3954C2839},
but a project with this GUID was not found in the .SLN file.

The weird thing is that from within VS.NET the project would build just fine. It turns out that the .sln file was missing “EndProject” line just above the GUID mentioned. Here is the fragment of the .sln file with the problem (fyi, I’ve wrapped the two project lines):

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VelocityProductionPlanning", 
"VelocityProductionPlanning\VelocityProductionPlanning.csproj",
"{4BAFD59F-EBB5-4FDA-8639-F7FC63F7F351}"
ProjectSection(WebsiteProperties) = preProject
  Debug.AspNetCompiler.Debug = "True"
  Release.AspNetCompiler.Debug = "False"
EndProjectSection
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VelocityLibraryMessaging",
"VelocityLibraryMessaging\VelocityLibraryMessaging.csproj",
"{14F4138C-4DA7-4029-A8D3-B1B3954C2839}"
EndProject

Notice, the project VelocityProductPlanning has no “EndProject” line. That caused MSBuild to generate the above warning and subsequently the build to fail.

Hope this helps.