Basically I want to block developers from building one of the projects in a solution that only the build server can/should build.
Alternatively, Developers would have a solution with projects A, B, C but not D. However, The build server would add project D to the solution. Then build the solution with projects A,B,C, & D.
Can this be done through code and/or configuration?
Thanks
Well one of possible solution would be creating different build configurations. Each build configuration would include projects needed to run properly.
Simplified example:
Developers could use default Debug
configuration to build projects A, B and C (D must be excluded from this configuration) to run application locally.
Production
configuration would have all projects (A, B, C and D) included, and your continuous integration system would use that configuration to build your solution.
Keep in mind what others said, you won't be able to protect project D from manual or accidental builds, as long as it stays inside same solution.