Respect build options (e.g., `--no-build`) during lock validation (#19366)
## Summary
Right now, `--no-build` et al are ignored during lockfile validation.
This PR wires them up, and improves lockfile validation to reuse static
metadata in one case that was surfaced by the change.