views:

39

answers:

2

Hello, I am developing a library which can be compiled for two different technologies. Basically, the users of the library should be able to compile the solution either for the Unity3D game engine or the NeoAxis game engine. The problem is: while the library is ready for the conditional compilation (#if UNITY using ... #endif, etc.), I can't find a way to enable a set of references or the other depending on the conditional compilation symbols.

Is it possible to do it? If so, how?

Thank you

+2  A: 

Go ahead and add all the necessary references. They will automatically be removed by the compiler if never used in your code which will be the case thanks to the #if/#endif. Another possibility is to provide two different .sln files referencing two different .csproj files pointing to the same source code but different references. There are many projects doing this: SomeProject_VS2008.sln and SomeProject_VS2010.sln.

Darin Dimitrov
+3  A: 

Yes but you have to do this in the msbuild .csproj file. This file is essentially just list of data, such as references.

What you do is add a Condition statement to both References.

<Reference ..a.. Condition="'$LibToUse' =='NeoAxis'" />


<Reference ..b.. Condition="'$LibToUse' =='Unitv3D'" />

Then just define command line var called LibToUse with the desired value.

Preet Sangha