Hi,
Every MSBuild element (ok almost every) can have a Condition associated with it. What I would suggest is that you edit the project file (which is an MSBuild file itself) and place all the SQL server references in an ItemGroup which has a condition on it for instance:
<ItemGroup Condition="'$(SqlServerTargetEdition)'=='2005'">
<!-- SQL Server 2005 References here -->
<Reference Include="..."/>
</ItemGroup>
And another ItemGroup for Sql server 2008:
<ItemGroup Condition="'$(SqlServerTargetEdition)'=='2008'">
<!-- SQL Server 2008 References here -->
<Reference Include="..."/>
</ItemGroup>
You should provide a default value for the property SqlServerTargetEdition before those items are declared. Then at the command line you can override that value using the /p switch when invoking msbuild.exe.