Handling projects in VS.NET 2003/2005 |
|
I recently ran into a problem where I had to maintain a set of projects in both VS.NET 2003 and VS.NET 2005. After struggling with this for a couple hours, I came up with a solution that seems to work. It is far from idea, because it involves having to maintain two copies of the project, but other than that (considerable!) defect, it compensates for Microsoft's inability to have solved this problem adequately. They still live in a delusional world in which the day on which a new product is released, all users instantly switch from the old version to the new version, and never find any problems that would require that they revert to the older system. Or have to maintain configurations that support both old and new builds. In the past, they were much better about this; but in the VS.NET2003-to-VS.NET 2005 transformation they completely lost the concept of backward compatibility, since the new system uses the same file names as the old system!
In particular, I needed to use the VS.NET 2005 support to build 64-bit applications (this is what the client would be using to build the 64-bit app, so I had to conform to that need. On the other hand, they did not wish to transition all their developers to using VS.NET 2005, partly because of its reputation for slowness, and part because of an inherent and well-justified distrust of any pre-Service Pack 1 software)
I spent some hours fiddling with this and came up with a solution. Here are the steps I used.
We are starting with a simple solution that has only one project.
We are starting with solution file is called project.sln and the project file project.vcproj.
Rename project.sln to project.2003.sln.
Rename project.vcproj to project.2003.vcproj
Copy project.2003.sln to project.2005.sln (in the same directory)
Copy project.2003.vcproj to project.2005.vcproj (in the same directory)
Invoke Visual Studio .NET 2005.
Open the solution called project.2005.sln
VS.NET 2005 will prompt to convert this project. Do so, and tell it not to bother to make a backup (your .2003. files are the backup)
In my case, I added the Win64 configurations.
Note the Configuration Properties, General, Output Directory and Intermediate Directory properties of the Win64 configuration is $(PlatformName)\$(ConfigurationName). Highlight one of these and copy it to the clipboard.
Note, however, that for the Win32 configurations, these
properties are simply set to Debug.
Paste the target descriptions into the Win32 configuration
Repeat this process for each of the Win32 configurations, such as Release, and any others that you have.
The result is a build tree set (for my project) that looks like this
...\project | +--- project.2003.sln +--- project.2005.sln | project | +---project.2003.vcproj +---project.2005.vcproj +---*.cpp, *.h, etc. | +---res | | | +---*.ico, *.cur, etc. | +---Debug | | | +---*.obj etc. built by VS2003 | +---project.exe built by VS2003 | +---Release | | | +---*.obj etc. built by VS2003 | +---project.exe built by VS2003 | +---Unicode Debug | | | +---*.obj etc. built by VS2003 | +---project.exe built by VS2003 | +---Unicode Release | | | +---*.obj etc. built by VS2003 | +---project.exe built by VS2003 | +---Win32 | | | +---Debug | | | | | +---*.obj etc. built by VS2005 | | +---project.exe built by VS2005 | | | +---Release | | | | | +---*.obj etc. built by VS2005 | | +---project.exe built by VS2005 | | | +---Unicode Debug | | | | | +---*.obj etc. built by VS2005 | | +---project.exe built by VS2005 | | | +---Unicode Release | | | +---*.obj etc. built by VS2005 | +---project.exe built by VS2005 | +---Win64 | +---Debug | | | +---*.obj etc. built by VS2005 | +---project.exe built by VS2005 | +---Release | | | +---*.obj etc. built by VS2005 | +---project.exe built by VS2005 | +---Unicode Debug | | | +---*.obj etc. built by VS2005 | +---project.exe built by VS2005 | +---Unicode Release | +---*.obj etc. built by VS2005 +---project.exe built by VS2005
To build under VS.NET 2003, open the project.2003.sln file; to build under VS.NET 2005, open the proejct.2005.sln file.
Of course, the obvious problem here is that I now have to maintain two project files, but I can build all twelve configurations.easily. Four builds (debug, Unicode debug, release, and Unicode release) built with VS.NET 2003, four 32-bit builds (of the same designations) built by VS.NET 2005, and four 64-bit builds (of the same designations) built by VS.NET 2005.
The views expressed in these essays are those of the author, and in no way represent, nor are they endorsed by, Microsoft.