Reputation: 20360
I have a solution that has to be built against different versions of dependency DLLs. I'd like to configure the solution to have different Configurations (targets) for different 'versions' of a target platform. (we're building libraries for a 3rd party framework and we have to target multiple versions)
I thought it would be relatively simple to set up the References for the solution to be different for each of the target versions, but I have not been able to do this successfully. i suspect that I am doing something wrong.
Attached is a screen shot.
As you can see I have made a number of 'target' configurations and I want the target configurations to be able to control which version of the dependencies the resulting DLL is built against.
We do not have control over those DLLs and can not rebuild to do the version call-forwarding differently.
Upvotes: 1
Views: 818
Reputation: 9639
I have not tried this, but you could try editing the csproj file in a text/xml editor, and adding a Condition to the references ItemGroups, e.g.,
<ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<Reference Include="System">
<Name>System</Name>
</Reference>
You would need to create an ItemGroup for each configuration where you need different references.
Alternatively, you may be able to use dependency injection to load the appropriate assembly at run-time. This will be easier if the referenced assemblies all implement the same interface, so that your calling code is coded against the interface and not the underlying implementation in the different assemblies.
Upvotes: 1