I have been wrestling with this for a few days and after tons of searching I can\'t find the path I should be on.
What I want to do is set up an MSBUILD project that
In a file like filter.targets add a target:
False
This will recreate the @(Reference) list to have the metadata 'Private' set to false, which will ensure that the reference doesn't get copied. Then run build your solution or project with the property $(CustomAfterMicrosoftCommonTargets) set to the path to this filter.targets file.
msbuild foo.sln /p:CustomAfterMicrosoftCommonTargets=c:\foo\filter.targets
This way, the BeforeBuild target will get invoked before building the project, and all references will be set accordingly. If you want more control over when or whether Private should be false or true, you can alter the BeforeBuild target and control that via properties.
Edit: There might be a better way to set the metadata in the BeforeBuild target.