Branch *.csproj file for building against .Net 4.0
I have 开发者_高级运维many libraries that are built using .Net 2.0 and 3.5
I now have a new winforms application that will build against .Net 4.0 but needs to reference the libraries.
Is this possible or is there a way to branch the *.csproj files of the libraries so that they have .Net 4 against them so I can use them in my new application
You can use them anyway, they don't need to be .Net 4.0.
There is the chance you will deploy to a machine that only has .Net 4.0, but you can set your installer to check for 3.5 and 4.0 as dependencies for the application.
Perhaps a different way to arrive at the result you want;
I have some libraries I keep versions of for multiple .NET versions, for example, but have mostly the same source code. I created separate projects for the 4.0 version project, and included the source code from the 2.0 version, but I included them as linked files instead of copying them.
This effectively does what you want, I guess; separate project files, but the same source code. Since I included the files as linked files, changes affect both projects, which are also in the same solution for convenience.
I then just define a preprocessor value in the 4.0 version for any differences which may need to be applied in the source.
This is the drop-down interface on the "Add" button on the Add Existing Item dialog in visual studio:
精彩评论