0

I am using Visual Studio 2010, and I have a solution where I need to build and test some of my projects in both .NET 2.0 AND .NET 4.0.

I could set up two solutions, one containing 2.0 Projects, the other ones containing the 4.0 projects. I could unload the 2.0 projects while building the 4.0 projects, and so on, there seem to be a lot of options.

What would be the best way to go about building/testing these projects? These projects might still change (fixes, ...), new files might be added, so is there a way to do this properly while being error prone as little as possible?

private_meta
  • 561
  • 4
  • 19
  • You should be able to set the runtime in the project settings. Are you able to? – Ryan Gates May 20 '14 at 13:50
  • Of course I am, but at the moment I have to switch between the two runtimes every time I build, because I need to build both, I want to avoid manual setting of runtimes as much as possible. – private_meta May 20 '14 at 13:51
  • Is the source code compatible? A lot will not be available in 2.0 that is in 4.0. – Ryan Gates May 20 '14 at 13:54
  • 1
    Make multiple "Configurations"....on your Solution choose Configuration Manager, then "copy" your "Debug" configuration, and name it "Debug NET 4", etc, etc...use the "Batch Build" so your "Solution Build" builds each Configuration.. otherwise get a book on MSBUILD and get the MSBUILD script to output multiple targets. http://msdn.microsoft.com/en-us/library/jj651644.aspx – Colin Smith May 20 '14 at 14:26
  • http://stackoverflow.com/questions/2923210/c-sharp-conditional-compilation-and-framework-targets – Colin Smith May 20 '14 at 14:32
  • @colinsmith your first solution sounds quite good. Do you know if there is a way to switch Startup Projects with your build configuration, as the startup project is one that needs to change as well? – private_meta May 20 '14 at 14:49
  • If you want to run/debug the NET 4 version, then just change the configuration to the "Debug NET4" one....otherwise change it to "Debug NET2" (or whatever name you decided to use to distinguish them) – Colin Smith May 20 '14 at 14:54
  • Yes, I know, but I meant: My startup project is ProjectA in Net20 and ProjectB in Net40, meaning when I switch configuration, I would have to switch the startup project, is that possible within the config or do I have to do that manually? – private_meta May 20 '14 at 14:55
  • 1
    This addin might lessen the pain of switching the startup project: http://visualstudiogallery.msdn.microsoft.com/f4e1be8c-b2dd-4dec-b273-dd88f8818571 (use the Smart, or Most Recently Used configuration option of that addin)....then you could record two macros where you "select" the name of the "startup project", followed by the "Build" action....then just alternate between running each macro (which will change the startup project to the different ones). – Colin Smith May 20 '14 at 15:32
  • @colinsmith You can paste together that information in an answer if you want me to accept it :) – private_meta May 21 '14 at 09:28

1 Answers1

0

As I don't enjoy my questions to be left open when they're answered, I'll writ eup what colinsmith wrote in the comments. If he chooses to post it as an answer himself, I'll accept that answer and delete this.

Make multiple "Configurations"....on your Solution choose Configuration Manager, then "copy" your "Debug" configuration, and name it "Debug NET 4", etc, etc...use the "Batch Build" so your "Solution Build" builds each Configuration.. otherwise get a book on MSBUILD and get the MSBUILD script to output multiple targets. http://msdn.microsoft.com/en-us/library/jj651644.aspx

Conditional Compilation and Framework Targets

If you want to run/debug the NET 4 version, then just change the configuration to the "Debug NET4" one....otherwise change it to "Debug NET2" (or whatever name you decided to use to distinguish them)

This addin might lessen the pain of switching the startup project: visualstudiogallery.msdn.microsoft.com/… (use the Smart, or Most Recently Used configuration option of that addin)....then you could record two macros where you "select" the name of the "startup project", followed by the "Build" action....then just alternate between running each macro (which will change the startup project to the different ones).

Community
  • 1
  • 1
private_meta
  • 561
  • 4
  • 19