Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Lazy Developer

by 'Jimmy' Skowronski


Working with .NET 1.1 in Visual Studio 2008 and Team Server

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:

  1. Download and install MSBee.
  2. 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.
  3. Import your 1.1 project into Visual Studio 2008.
  4. Unload the project and edit the project file.
  5. 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">

  6. 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" />

  7. Close the file and reload the project. You may have to answer a security dialog where you shall choose "Load project normally" option.
  8. In Visual Studio 2008 go to the Configuration Manager.
  9. Select "New..." from the dropdown under "Active solution platform".
  10. Select ".NET 1.1" or ".NET 1.1 Web" for a web project and click OK.
  11. 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:

  1. 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.
  2. 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.
  3. Similar thing can happen when you drop control from the toolbox to a page.
  4. 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:

  1. Install MSBee and deploy target files on your build machine.
  2. 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">
         <
    FlavorToBuild>Debug</FlavorToBuild>
         <
    PlatformToBuild>.NET 1.1</PlatformToBuild>
    </
    ConfigurationToBuild>

And that is all. HTH.



Comments

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# August 22, 2008 10:49 AM

Dew Drop - August 23, 2008 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop - August 23, 2008 | Alvin Ashcraft's Morning Dew

# August 23, 2008 10:17 AM

Reflective Perspective - Chris Alcock » The Morning Brew #165 said:

Pingback from  Reflective Perspective - Chris Alcock  &raquo; The Morning Brew #165

# August 26, 2008 2:34 AM

Srinivas Yelamanchili said:

Hi, the MSBee installed 'MSBuildExtras.Fx1_1.*.targets.' files in the Program Files/MSBuild/MSBee directory, and not the CrossCompile files

Also, i am using Visual Basic 2008 Express Edition and under Build menu, the only options are for Build and Publish, there is no Configuration Manager.

Under Solution properties -> Compile -> Advanced Compile options -> Target Framework only lists 2.0/3.0/3.5 even after the editing the project file to:

<Import Project="$(MSBuildExtensionsPath)\MSBee\MSBuildExtras.Fx1_1.VisualBasic.targets" />

Thanks,

-srinivas

# August 27, 2008 12:57 AM

Jimmy said:

I'm not using *target files from MSBee in this post. Approach is generally the same bur implementation a bit different and requires CrossCompile files. However no one said that you have to use that method if MSBee suits you well.

As for Visual Studio Express - I trust your words for I've never used that version. Version I'm writing about (from Professional upward) has Configuration Manager.

# August 27, 2008 3:59 PM

mike said:

I did not find your configuration file "CrossCompile.CSharp.targets" mentioned in step 2 of your guide. Where can I download it?
# September 19, 2008 5:47 AM

pfm said:

At the bottom of the post, in fairly small font, and partially displaced by an ad: Published Aug 22 2008, 03:03 PM by Jimmy Filed under: Visual Studio, Tips & Tricks, TFS **Attachment: CrossCompile.CSharp.zip**
# October 10, 2008 1:39 PM

Jimmy said:

pmf - thanks :)

# October 21, 2008 2:54 PM

liviner said:

ZIP file download says it's corrupt, and I've tried to get it from multiple machines.  Any problems with the file?

Thanks!

# November 7, 2008 5:06 PM

Peter Rietmann said:

Hi , firstly thanks for the great post. I have followed your directions and have .NET 1.1 Project loaded in VS2008 / TFS and it works fine, I can build no problem. I have tried adding to the TFSBuild.proj but I get there some strange errors such as C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets : warning MSB3106: Assembly strong name "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System" is badly formed. It may contain characters that need to be escaped with backslash(\). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).

for each of the net 1.1 references.

If  I run this command in command prompt I get the same exceptions

"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"  "E:\Drop\Sources\Common.sln" /build "Debug|.NET 1.1"

Any ideas what can be wrong ?

# November 12, 2008 8:32 AM

Joe said:

Will this work for vb.net applications as well?

# November 14, 2008 3:02 PM

Jimmy said:

liviner: You are the first with problems with file. Send me your email so I can email you files.

Peter: Looks like you have to change build type to ".NE 1.1" in TFSBuild.Proj. There is section that describes build configuration. Check that please and let me know if that helps.

Joe: No idea but I can't see why it shouldn't. Try and let me know.

# November 16, 2008 2:07 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Jimmy

I currently work for MessageLabs, one of the best security companies in the world! I love the Microsoft technology stack and use it to make my company successful! Not only work is my life. I love mountains and climbing. That feeling when I'm on the wall and there is nothing around me, only void. When I can feel stone on my fingers, every tiny bit, when my fingers are going wet and chalk doesn't help, when my muscles and body are exhausted. Damn, I'd love it. Even more than programming. Check out Devlicio.us!

Our Sponsors

Red-Gate!