views:

34

answers:

2

I have a project that runs on both .NET and .NET CF. But it uses a 3rd party library that will not run on both. So I end up changing the reference every time the project gets built.

Project A - References the 3rd party dll.

Project B - References A and runs .NET CF

Project C - References A and runs .NET

Is there a way to automate it?

Here is a link to that 3rd party library: http://dotnetzip.codeplex.com/Wikipage

+1  A: 

You could make separate solutions and setup build configurations appropriately for each. You would have to maintain both solutions manually, though, from then on.

Alex
Yeah that is what I would like to avoid.
NitroxDM
I could, however create an interface and then have two implementations. That would minimize the maintaining two projects...
NitroxDM
According to http://social.msdn.microsoft.com/Forums/en/vsx/thread/f032a9b7-50d5-4459-bd2f-5bfe2d6022c2, we can't expect this from MS but there may be 3rd party tools.
Alex
+1  A: 

You can set up two build configurations in your solution - one for .Net and one for .Net CF - and use conditional references to switch which version of the library is referenced.

Set up two new build configurations for .Net and .Net CF (the same as you would for debug and release configurations ie. Build -> Configuration Manager). Add both the .Net and the .Net CF 3rd party dlls as references to project A. You will then need to hand-edit the project file for project A - see my previous answer for how to do this. Make sure you set project B to not build in the .Net build configuration and project C to not build in the .Net CF build configuration.

This enables you to build either a .Net output or a .Net CF output based on the currently selected build configuration, all within one solution, all using the same projects.

adrianbanks