I am using a pre-build task in Visual Studio 2008 that invokes msbuild:
C:\\WINDOWS\\Microsoft.NET\\Framework\\v3.5\\MSBuild.exe $(MSBuildProjectDirectory)\\
+1 for the trick, although neither the accepted solution nor the linked article specified that the line should be added to the first element in the .csproj file.
It is also a problem with Visual Studio only, as invoking msbuild from the command-line on the same .csproj file (without the trick) will see the generated code files compiled right away (and not the previous versions).
Also, I would like to recommend that this topic be tagged with the following, as I had to dig a lot to find it: