I made a new solution and it worked correctly at first. I added a class library for tests, and two class libraries for things to test. Added references and ran unit tests without a manual compile and it worked fine.
Unloaded and re-loaded VS.NET and unit tests still ran fine.
HOWEVER, once I added a web project to the solution (even though the unit tests don't reference the web project), the test solution began failing.
WebSite: Debug|.NET
D1: Debug|Any CPU
D2: Debug|Any CPU
Tests: Debug|Any CPU
In Build Configuration, Debug|.NET config doesn't include D1,D2, and Tests projects.
When we execute DTE.Solution.SolutionBuild.BuildProject("Debug", ...) it tries to build D1 & D2 as dependent projects, but for unknown reason (probably a bug in VS) it starts "Debug|.NET" for dependent projects, it failes to build them. Note, that in output window it displays "Debug Any CPU", since ProjectConfig is "Debug" and "Platform" is "Any CPU", but
SolutionConfig is "Debug|.NET" as seen by events.
The workaround would be to open "Build \ Configuration Manager...", select ".NET" platform and put checkmarks for each project.