Avoid workspace-wide locks when building.

There is no reason to lock the workspace when building a project. Markers already
lock the required resources, and the build should just lock the current project.

Fixed #1001631.

(should be backported)