MSBuild rework

I took the liberty of doing some cherry-picks and rewording @johansson work. Thoses changes are tested and non-breaking.