I was trying to write that post for so long that I've started worry that there will be new version of the Visual Studio before I will even start. Finally, I found some time and here it is.
What I'm going to write about here is how to use the latest IDE to work with a .NET 1.1 applications. Before you will start asking why one would like to do so, there is an answer: because you can. But seriously speaking, I prefer to use much more matured IDE than the very 2003 version. There is also other, even more important reason - TFS. By importing your 1.1 projects into VS2008 you can use full benefits of TFS. That is worthwhile. So let's get started.
For quite a long time I was using MSBee and VS2005 however I was not happy with that and when I advanced to the 2008 version I started looking for something else. Everything started from the great post Jomo Fisher published on his blog "Hack the Build: Targetting .NET Runtime 1.1 Step-by-Step" and later update "Hack the Build: Use Whidbey Beta2 to target .NET Runtime 1.1" where he described approach that is a way better than using MSBee. Everything was working fine except resources. Jomo uses ResGen task from devices version of the MSBuild but from some reason that seems not working for me. Finally, after some tests I found that adequate tasks from MSBee are working just fine.
Visual Studio 2008
There are simple steps how to do that:
- Download and install MSBee.
- Download zip file attached to this very post. Put them into your MSBuild folder, typically "C:\Program Files\MSBuild\" or "C:\Program Files (x86)\MSBuild\" if you are living in 64 bit world.
The first one CrossCompile.CSharp.targets contains all information required to build most of the .NET 1.1 projects except the web and web services which. The latter are covered by the second file.
- Import your 1.1 project into Visual Studio 2008.
- Unload the project and edit the project file.
In the very first line you will see:
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Change the value of the ToolsVersion attribute from 3.5 to 2.0 so the line will looks like below. That will tell the MSBuild to use version from .NET 2.0 instead of 3.5.
<Project DefaultTargets="Build" ToolsVersion="2.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Near the bottom of the project file you will find an Import tag that looks like:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Replace that with:
<Import Project="$(MSBuildExtensionsPath)\CrossCompile.CSharp.targets" />
or with that, if you have a web project:
<Import Project="$(MSBuildExtensionsPath)\CrossCompile.CSharpWeb.targets" />
- Close the file and reload the project. You may have to answer a security dialog where you shall choose "Load project normally" option.
- In Visual Studio 2008 go to the Configuration Manager.
- Select "New..." from the dropdown under "Active solution platform".
- Select ".NET 1.1" or ".NET 1.1 Web" for a web project and click OK.
- Build. You can add Generics namespace somewhere and check if there will be an error if you want to ensure that everything is working fine.
That's all. Now you can use the latest VS to work with .NET 1.1 projects. Almost everything works as it should. You can run and debug, add new classes etc. You can also mix .NET 1.1 compatible and newer projects in a single solution, including test projects.
However, there are some limitations you should be aware:
- Visual Studio will use .NET 2.0 template to add a new class. That means you will have to remove Generics namespace declaration from the class. One can play with templates and tweak them but I don't see that as a problem.
- There is a bit bigger issue for web applications. From the same reason as above, Visual Studio will use aspx page template from the 2.0 framework which uses partial classes to separate your code from generated by the IDE. That means you have to manually tweak every page just after you added it. It's not a big problem however. My colleagues are using that method every day from quite a few months and we are fine.
- Similar thing can happen when you drop control from the toolbox to a page.
- I haven't done any extensive tests with forms applications and user controls. It builds but I have no idea how IDE will behave. You will have to find that yourself.
Team Foundation Server
There is not too much to write about TFS in that context. Once you create a team project and build you need to remember about two things:
- Install MSBee and deploy target files on your build machine.
Remember to enter correct platform when you create new build. You can always edit TFSBuild.proj file later. Either way you should have:
<ConfigurationToBuild Include="Debug|.NET 1.1">
And that is all. HTH.
08-22-2008 3:03 PM