[RESOLVED] One project that targets 2 versions of the framework
Hey :)
I don't think this is possible but thought I'd just double check...
I have a class library project (i.e building this project results in a DLL being created) and I add a reference to this DLL in several of my other applications. This DLL project targets .NET Framework v2.0.
However, some of these apps that use the DLL target .NET 2.0 (or 3.5) and some target .NET 4.0. But because .NET 4.0 does not include 2.0 and 3.5 in it, its possible for someone to have .NET 4.0 installed but not .NET 2.0, therefore meaning that they won't be able to run my app because of the reference to a DLL that requires .NET 2.0.
So the solutions as far as I can see are:
1. Include .NET 2.0/3.5 as an additional prereq for my .NET 4.0 apps... ewww.
2. Create a copy of this DLL project and make it target .NET 4.0 then in my .NET 4.0 apps add a reference to that rather than the .NET 2.0 version.
So far I've been using the second option, which is working fine but its just very annoying having to remember to copy and paste any changes I make in one version of the DLL project into the other one.
So is there any way I can have a single DLL project but have it build 2 versions of the DLL, one targeting .NET 2.0/3.5 and one targeting .NET 4.0?
As I've written this down I've just realised I could always build the solution, copy the DLL out to another folder, then change the target framework and build it again to get the new DLL but that's still not ideal.
Using VS 2010 Ultimate by the way in case that makes any difference to the options I've got available
Thanks
Chris
Re: One project that targets 2 versions of the framework
You say ewww to option 1 but are ok with option 2?!?!?!? I'd be saying ewww to option 2, and for the reasons that you only seem to find mildly annoying. I think option 1 is the best solution, by far. After all, if you are just setting it as a prerequisite, then nothing happens if it is already there. Since 2.0 was pushed out as an important update to all XP OS, and is most likely pre-installed on anything newer, you are picking up the bulk of the user base for no cost if you add the prerequisite. Only a few will need the additional installation.
Re: One project that targets 2 versions of the framework
I'd probably have two project files... side by side, that then have the same code files referenced... each project file will then target the different FWs.
example:
Form1.vb
Form2.vb
SomeOtherForm.vb
AClass.vb
AClass2.vb
MyProject2.vbproj < -- this targets FW2.0/3.5 or what ever
MyProject4.vbproj < -- this targets FW4.0
All in one folder.
-tg
Re: One project that targets 2 versions of the framework
Quote:
Originally Posted by
Shaggy Hiker
You say ewww to option 1 but are ok with option 2?!?!?!? I'd be saying ewww to option 2, and for the reasons that you only seem to find mildly annoying. I think option 1 is the best solution, by far. After all, if you are just setting it as a prerequisite, then nothing happens if it is already there. Since 2.0 was pushed out as an important update to all XP OS, and is most likely pre-installed on anything newer, you are picking up the bulk of the user base for no cost if you add the prerequisite. Only a few will need the additional installation.
well yeah if it was a big project I can see why option 2 would be awful but its only a fairly small project and I don't update it that often so it is only a mild annoyance. I just don't like the idea of targetting .NET 4.0 Client Profile in my apps because of its small download size but then potentially having to download the full .NET 2.0 or 3.5 installs as well just for the sake of this one DLL (especailly when its a DLL that I can control the target framework version of). You are probably right though about 90% of the users already having .NET 2.0 so I guess I shouldn't be that bothered about having to install it on the few that don't... I'm still interested to know if its possible to have a project that builds multiple assemblies targetting different frameworks though :)
Re: One project that targets 2 versions of the framework
Quote:
Originally Posted by
techgnome
I'd probably have two project files... side by side, that then have the same code files referenced... each project file will then target the different FWs.
example:
Form1.vb
Form2.vb
SomeOtherForm.vb
AClass.vb
AClass2.vb
MyProject2.vbproj < -- this targets FW2.0/3.5 or what ever
MyProject4.vbproj < -- this targets FW4.0
All in one folder.
-tg
Thanks TG, I did briefly consider that but for some reason thought that it would be pretty messy to setup but it might not be that bad actually and might be the best option
Re: One project that targets 2 versions of the framework
We do something similar here... code development in in VS2010.... but all of our SSRS projects are still maintained in VS2005... the process to load the report belongs to VS2010... so the rdl gets shared by both the VS2010 project file and by the VS2005 project file. Works quite well.
-tg
Re: [RESOLVED] One project that targets 2 versions of the framework
Going with TG's suggestion, certainly better than what I had before.
For anyone else wanting to do the same thing, when you add the files to the second project make sure you use the little drop down arrow on the Add button to change it to Add As Link otherwise you will just create a second copy of the .vb files and changes made in one project wont affect the other :)