I'd like my VS extension to be able to change the value of an MSBuild property before building a project. The BuildProjectReferences property is used by Microsoft.Common.targets to decide whether to touch project references during the Clean target. I'd like to temporarily set BuildProjectReferences=false and then build the project that is currently selected in Solution Explorer.
If this is possible, this would be the best way for my extension to provide "Clean Project Only" and "Rebuild Project Only" commands for C# and VB projects. Setting the BuildProjectReferences property is easy from the MSBuild command-line, but I'd like to be able to hook into VS's use of MSBuild. Unfortunately, I don't see a way to do this from the SolutionBuild interface. If it's not directly possible through a VS interface, is there some other clever alternative (e.g., set an environment variable and hope MSBuild will treat it like the property value)?
FWIW, C# and VB normally build super-fast, so it isn't a big deal to have project references build automatically. However, at work I have several large solutions with lots of dependent projects where each project also runs Code Analysis,StyleCop, and a large post-build step. Those extra steps add a non-trivial amount of time, so there are occasions where a quick "Rebuild Project Only" command would be nice. Unfortunately, VS's Build.RebuildOnlyProject command is only available for C++.
So my questions are: how can I set a custom MSBuild property value before building the selected project with a VS-integrated build, and if it's possible, then what's the best way to do this?
Thanks for your help!