Hack the Build: Use Whidbey Beta2 to target .NET Runtime 1.1

Hack the Build: Use Whidbey Beta2 to target .NET Runtime 1.1

Rate This

Jomo Fisher – A while back, I posted a sample that showed how to target the .NET 1.1 runtime (the version that came with Visual Studio .NET 2003 also known as Everett) with MSBuild. Now Beta 2 has rolled around and I can see that there have been enough changes to MSBuild to warrant an entire rewrite of that original sample.

I’ll get into the details of how it all works down below, but right now let’s just get it working on your machine. Here are the steps:

(1)   Copy this MSBuild targets file to “C:\program files\msbuild\CrossCompile.CSharp.targets

(2)   Create a new C# project somewhere called MyApp.

(3)   Use notepad to edit MyApp.csproj. Replace the entire <Import> tag with

  <Import Project="$(MSBuildExtensionsPath)\CrossCompile.CSharp.targets" />

(4)   When prompted, reload the project. You’ll have to answer a security dialog.

(5)   In VS, click the drop-down that says ‘Any CPU’ and select ‘Configuration Manager’

(6)   Under Active Solution Platform, select <New…>

(7)   Select ‘.NET 1.1’ (pretty cool, eh?) and press OK.

(8)   Build and notice error about System.Collections.Generic. This means its working because generics aren’t supported in 1.1.

(9)   Open Program.cs and delete the line:

using System.Collections.Generic;

     And rebuild.

That’s it, its working.

As with the last sample I posted on this, I expect that only basic scenarios will work here. If you run into a problem, drop me a note. If I see a quick solution I'll post it. Otherwise, I can still publish those limitations here so that other people can learn from your experience.

What’s New?

There are some differences between this version and the prior sample I published that show off some nice new features in MSBuild for Beta2:

  • This version shows how to add entirely new Platforms for VS to pick up. See the $(AvailablePlatforms) property in CrossCompile.CSharp.Targets. You could, pretty easily, add other targets from .NET 1.0 or any other tool that is roughly command-line interchangeable with CSC.EXE.
  • The reference resolution logic in this version is far more robust. Many more scenarios should work now, including references to third-party assemblies as well as project-to-project references. (Though you still can't reference 2.0-compiled assemblies into 1.1 projects--this is a limitation built into the CLR itself).
  • We’ve added a new built in property called $(MSBuildExtensionsPath) which is defined to be like “C:\Program Files\MSBuild”. This is a well-known spot where people can dump their custom targets files. This saves you from having to hard-code a path in your project or template.
  • Targets can now be entirely overridden. The GetFrameworkPaths targets from Microsoft.Common.Targets is overridden in CrossCompile.CSharp.Targets so that an alternate directory for target framework directory can be injected.
  • This version doesn’t build 2.0 and 1.1 at the same time. This is nicer, I think, because otherwise you see duplicate errors when you build.

Moving On

At the end of this month I'm moving from the MSBuild team (5th floor, building 41 in Redmond) to the C# team (1st floor, building 41 in Redmond). Working on MSBuild has been a blast and I intend to keep on blogging about it if I think I having something of value to say. After a while, I hope to have something useful to say about C# too. I think "Hack the Build" still fits, so I'll keep the name.

This posting is provided "AS IS" with no warranties, and confers no rights.

Leave a Comment
  • Please add 1 and 6 and type the answer here:
  • Post
  • OK, this is pretty cool.. so now for another challenge: supporting the same mechanism for ASP.NET 1.1 websites.. and not have VS.NET mess up the code when converting to a VS 2005 project....
  • The line:
    <UsingTask TaskName="CFResGen" AssemblyFile="$(MSBuildBinPath)\Microsoft.CompactFramework.Build.Tasks.dll" />

    Implies a requirement for the CompactFramework. Installing the 'Smart Device Programmability' in VS2005. I was getting a build error (similar to one above, about not being able to find something for CFResGen). The fix was installing the compact framework (maybe the tasks are defined in another assembly, but I wasn't sure).

    But I would like to say that it still works great in VS2005 'final,' and thanks for the doc.
  • Thank U for this info. It was very useful in solving a problem with compiling a C# project with MySQL .NET 1.0.7 connector on VS2005 for .NET Framework 1.1.

    You are the greatest!
  • Jomo,
    Thank you very much for posting this tip.
    Imagine this, you are at VSLive! 2006, learning all about the wonders of VS2005 and you want to start using it right away. Problem is you have apps to support back home that sit on machines with only 1.1 installed. That's what is happening to me. It was VERY frustrating. So, I spent the evening working with your 'hack', learned some things about the environment, and now can move forward developing new apps for 2.0 and still support older ones.
    Thanks --
    Jay
  • I am using a full install of "Visual Studio 2005", but when i try to build i recieve the following error, in all the forms i have (they are ALL created with VS2003, and the converted by VS2005):

    error: Invalid ResX input.
    error: Specific exception: FileNotFoundException  Message: Invalid ResX input. ---> FileNotFoundException: File or assembly name System.Drawing, or one of its dependencies, was not found.

    What can i do to resolve this issue??

  • SharpDevelop 2.1, revision 1157, allows VB.NET projects to target the older Microsoft Frameworks and...
  • PingBack from https://chodavarapuravi.wordpress.com/2005/06/16/visual-studio-2005-compatibility-mode/
  • Is there a new version of this document matching the final release of VS.NET 2005?
  • J. Fisher describes how to achieve this on his blog post here
    http://blogs.msdn.com/jomo_fisher/archive/2005/04/22/410903.asp...
  • Very frequent question from the users of Visual Studio 2005 is &quot;what should I do to&amp;nbsp;build .NET Framework...
  • I was recently asked if it was possible to utilise Compact Framework 1.1 with VS2005.&amp;nbsp; I recollected...
  • Can anyone tell me how to do the same but in Visual Basic?

    if yes, please send me an email at cerb7@wp.pl

  • Thank you Jomo, very much!

    This is going to have a major affect to our project.

  • <a href= http://forum.lixium.fr/cgi-bin/liste.eur?wellbut > wellbutrin medication </a> [url= http://forum.lixium.fr/cgi-bin/liste.eur?wellbut ] wellbutrin medication [/url]

Page 2 of 8 (107 items) 12345»