views:

245

answers:

2

I've currently got a C# code base that is compiled into a library. I have two clients each requiring only a selected sub set of the methods available and management are concerned that they may share files to get access to other methods they have not paid for (paranoid).

To reduce complicating the project I've created two Setup projects that include the primary output of the code project and wish to supply /define arguments to the compiler on a per Setup project basis to remove certain methods.

Is this possible?

Is there a better way to approach this?

Thanks for the replies.

+1  A: 

I don't get the "swap files" angle, swap with what? But, no, a setup project can't compile code. You'd need separate build projects or leverage #ifdef.

Hans Passant
If one client had more functionality than the other they could swap (share) their version.
Ben Crowhurst
Leverage #ifdefThis is what I'm looking to do but how can each Setup project specify /define to the code project?
Ben Crowhurst
You cannot stop two different clients exchanging files with each other by anything you could do at build or setup time. License terms are enforced in a court of law.
Hans Passant
A: 

If it's a licensing question, I'd be tempted to suggest that you check the license with each method that's called, though this may add significant overhead.

Alternatively, you'd be better off creating two Visual Studio Projects, each containing only the sub-set that each client needs, and naming each one after the client that needs it. They can both share the same source files, but be built into two different binaries.

I'm assuming that you're shipping the library as your product, rather than shipping a product that uses the library?

Xav