Josh
Josh

Reputation: 16532

Build a library dll in multiple frameworks

I have seen a lot of libraries that are released in multiple frameworks. In any framework you choose, the library namespaces are the same, but the dll is compiled in .net 2.0, 3.5 or 4.0.

What is the standard or best practice way of having the same code built in the various frameworks? I'm curious if there is code duplication going on or if there is a better way.

Upvotes: 4

Views: 611

Answers (2)

Davide Piras
Davide Piras

Reputation: 44605

a viable way would be to have a solution with multiple projects or even multiple solutions which you open one by one in Visual Studio but the project files (C# or VB.NET) always point to the same file in the file system.

for example, multiple projects in the same solution, one project contains the file normally and the other projects have a link to the file, added by using right click on project, add existing item, selecting the file then click arrow down in Add button and select Add as Link.

of course if inside the file contains code which belongs to certain frameworks only you should put the if or #ifdef and so on...

Upvotes: 4

SLaks
SLaks

Reputation: 887767

Make two copies of the project file in the same folder, and edit the Target Framework in one of them.

Every time you add a new source file, you'll have to include it in the second project.

Upvotes: 1

Related Questions