开发者

Build a library dll in multiple frameworks

开发者 https://www.devze.com 2023-04-05 07:39 出处:网络
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.

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.


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...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消