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


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.

Comments (107)

  1. Daniel Moth says:

    Blog link of the week 16

  2. interscape says:

    I think there’s a bug in the targets file. I think this line (in the PropertyGroup)

    <TargetFrameworkVersion>v1.0</TargetFrameworkVersion>

    Should read like this:

    <TargetFrameworkVersion>v1.1</TargetFrameworkVersion>

    I’m not 100% sure. You’d know better than I do.

  3. Good eye for spotting that TargetFrameworkVersion issue. However (and unfortunately) the code will only work the way it is now. This property is only used to remove references to warnings that only exist for CSC 2.0. See mention of this property in Microsoft.CSharp.targets.

    We hope to fix this issue in Microsoft.CSharp.targets before we ship.

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

  4. Jomo Fisher has posted an update of his build targets for VS2005 beta 2, with these, you can build apps…

  5. TM says:

    Since the release of&amp;nbsp;beta2 of Visual Studio 2005 I have been looking for a way to code in beta2…

  6. TM says:

    Since the release of&amp;nbsp;beta2 of Visual Studio 2005 I have been looking for a way to code in beta2…

  7. Thanks for the info! Sorry to see you leave the MSBuild team

  8. casey says:

    Very cool. Perhaps it will be possible to add Mono and IKVM targets as well!

  9. Ryan Schneider says:

    I’ve tried using this in Express Beta 2, but am getting an error.

    When I do a build, I get the following 1 warning and 1 error:

    Warning 1 The "CFResGen" task could not be loaded from the assembly C:WINDOWSMicrosoft.NETFrameworkv2.0.50215\Microsoft.CompactFramework.Build.Tasks.dll. Could not load file or assembly ‘file:///C:WINDOWSMicrosoft.NETFrameworkv2.0.50215Microsoft.CompactFramework.Build.Tasks.dll’ or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, and that the assembly and all its dependencies are available. C:Program FilesMSBuildCrossCompile.CSharp.targets 0 0

    Error 2 The "CFResGen" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:WINDOWSMicrosoft.NETFrameworkv2.0.50215" directory. C:Program FilesMSBuildCrossCompile.CSharp.targets 113 3

  10. Ryan Schneider says:

    Replacing occurances of "CFResGen" with just plain "ResGen" seems to do the trick for me. I assume "CF" refers to the compact framework, which isn’t part of Express, correct?

  11. Is it possible? Yes, it is possible, though not without a little finesse.

    &amp;nbsp;

    Jomo Fisher has a…

  12. 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….

  13. 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.

  14. Pavel Myshkin says:

    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!

  15. Jay Hamlin says:

    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

  16. Nick says:

    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??

  17. Matt Ward says:

    SharpDevelop 2.1, revision 1157, allows VB.NET projects to target the older Microsoft Frameworks and…

  18. jwezel says:

    Is there a new version of this document matching the final release of VS.NET 2005?

  19. Very frequent question from the users of Visual Studio 2005 is &quot;what should I do to&amp;nbsp;build .NET Framework…

  20. I was recently asked if it was possible to utilise Compact Framework 1.1 with VS2005.&amp;nbsp; I recollected…

  21. Chris says:

    Can anyone tell me how to do the same but in Visual Basic?

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

  22. Alex says:

    Thank you Jomo, very much!

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

  23. Donna says:

    Today was a complete loss. I feel like a fog. I’ve just been hanging out doing nothing, but eh…

  24. Linda says:

    I’ve just been letting everything pass me by lately. I’ve more or less been doing nothing. Not much going on lately. I can’t be bothered with anything recently.

  25. Alise says:

    Not much on my mind recently. I haven’t gotten much done. What can I say? I haven’t been up to much these days, but such is life. I feel like a complete blank, but so it goes…)))

  26. Ron says:

    My life’s been dull. I just don’t have much to say right now, but it’s not important. More or less nothing seems worth thinking about.

  27. Peter says:

    I just don’t have much to say right now. Pretty much nothing seems worth doing. My mind is like an empty room. I haven’t gotten anything done these days. What can I say?

  28. Mikle says:

    Good site! Well.. i like design!

  29. Milas says:

    Well…good news, i like your site, Happy new year! )))

  30. taliawe says:

    Excellent browsing have the to

  31. webmaster says:

    Excellent browsing have the to

  32. Dingo says:

    real good news! good site, respect webmaster!

  33. Marsha says:

    This is a wonderful page for everyone! Please visit my site too:

    <a href=  ></a> [url=][/url]

  34. tosc says:

    Excellent browsing have the to

  35. ware,ware says:

    While site keep Good work,While site keep Good work

  36. chat,chat says:

    Beautiful site!,Beautiful site!

  37. sarde,sarde says:

    Very interesting.,Very interesting.

  38. lianet says:

    Excellent browsing have the to

  39. miami says:

    Excellent browsing have the to

  40. I will recomend this site… Excelent work!!! May I use your palette at my site? Thanks!,I will recomend this site… Excelent work!!! May I use your palette at my site? Thanks!

  41. card says:

    Excellent browsing have the to

  42. card says:

    Excellent browsing have the to

  43. italiitali says:

    Excellent browsing have the to

  44. shutgunst1 says:

    Doing correct [url=http://www.linkwizard.net]link exchange[/url] could bring a lot of traffic.

    Are natural links more important then links from "link" pages or se don’t care?

  45. Romanson says:

    Good Info, I found you at the Google, thought u might wish to know.

  46. Bill says:

    More information, you work, stress, then you focus on a creative. Appraisal discussion, ask figure of his new overcome, or off to describe. Foundation for them out the basic level, this regularly undertake a [url=http://learnin.43i.net ]learning center.[/url].

  47. Linkin park says:

    Best my wishes to Admin. Plz look my site too:

    <a href=http://linkin-park.creablog.com>linkin”>http://linkin-park.creablog.com>linkin park concert ticket</a> | [url=http://linkin-park.creablog.com]linkin park concert ticket[/url] | http://linkin-park.creablog.com – linkin park concert ticket !  Thanks.  p.s. Linkin Park Concert Ticket

  48. Good Site .Nice work.,Good Site .Nice work.

  49. ... says:

    Lavoro eccellente! ..ringraziamenti per le informazioni..realmente lo apprezzo: D

  50. ... says:

    The information I found here was rather helpful. Thank you for this.

  51. ... says:

    ..Rather helpful information you have here. Grazie!

  52. ... says:

    E evidente che il luogo e stato fatto dalla persona che realmente conosce il mestiere!

  53. ... says:

    um… buoni, realmente buoni luogo e molto utile;)

  54. ... says:

    Lo trovo piuttosto impressionante. Lavoro grande fatto..)

  55. Doxycycline says:

    Re: <a href=http://medjetnet.info/doxycycline/buy-doxycycline.html>Doxycycline</a>”>http://medjetnet.info/doxycycline/buy-doxycycline.html>Doxycycline</a> is used to treat bacterial infections, including pneumonia and other respiratory tract infections; Lyme disease; acne; infections of skin, genital, and urinary systems; and anthrax (after inhalational exposure). It is also used to prevent malaria. Doxycycline is in a class of medications called tetracycline antibiotics. It works by preventing the growth and spread of bacteria. Antibiotics will not work for colds, flu, or other viral infections.

    [URL=http://medjetnet.info/doxycycline/buy-doxycycline.html]buy doxycycline[/URL]|

  56. Senthil kumar says:

    Hi All

    Why Microsoft is not supporting Framework 1.1 in visual studio. any specific Reason behind this other than business developement.

  57. farhan says:

    awesome it works great.. thanks to you ill never forget this site

  58. dokka says:

    I have a problem in your design. I use Firefox in Ubuntu.

  59. mokka says:

    Very ineresting web site. I like many post. I have say you THANK YOU VERY MACH

  60. bokka says:

    Thank you fpr you.I want copy this site.

  61. Lucy! Please call me,Lucy! Please call me

  62. JustJack says:

    Good Lord Jomo, clean this crap out…

    The CSharp.Targets file was renamed between earlier Beta releases and Beta 2 of Visual Studio. Look for the file as Microsoft.CSharp.targets in the WindowsMicrosoft.NETFrameworkv2.0.50215 directory. Simply update the filename of the targets file from CSharp.Targets to Microsoft.CSharp.Targets in the .csproj file.

  63. Buy Caverta says:

    This is really fresh idea of the design of the site! I seldom met such in Internet. Good Work dude!

  64. jrummell says:

    Wow, to think I could have been using VS 2005 to maintain 1.1 apps … thanks for sharing!

  65. 最远距离 says:

    这是鬼佬教的方法,原帖地址:

    http://blogs.msdn.com/jomo_fisher/archive/2005/04/22/410903.aspx 由于MSBuild未能直接提供…

  66. Chris Odd says:

    Regarding instruction (3):

    >>Use notepad to edit MyApp.csproj.

    I’ve converted a web application from VS2003 to VS2005.  It no longer has a .csproj file as .csproj files have been obsoleted for these types of applications.

    How do I target this app for .Net Framework 1.1?

  67. Mark Deraeve says:

    I’m havind troubles building my solution to 1.1. All the projects are build in VS2003 and imported later. I have changed the code after. I keep getting this error: Error 3 "resgen.exe" exited with code -1163019603. FilterMonitor

    It doesn’t help me a lot does it?

    Any suggestions?

  68. pribadi dewa says:

    is there another way to build asp.net 1.1 using VS 2005 C# ? there’s no csproj file in Solutions folder

  69. Alinsa says:

    <a href= http://index1.brighturn.com >welfare recipients have a choice too breastfeeding</a> <a href= http://index4.brighturn.com >sex offendersin middle twp. nj 08210</a> <a href= http://index5.brighturn.com >winston salem state university phat booty pics</a> <a href= http://index3.brighturn.com >pics</a> <a href= http://index2.brighturn.com >university of massachusetts</a>

  70. Brian says:

    And for all those who are still upgrading – this works in VS2005 Team edition for Developers – I’ve just done it using a new project.

  71. I was trying to write that post for so long that I&#39;ve started worry that there will be new version

  72. I was trying to write that post for so long that I&#39;ve started worry that there will be new version

  73. Chris says:

    Thanks for the great work on compiling CSharp targets.  I was able to use this to compile .NET 1.1 projects in VS2008.

    Would you happen to have a version for VB.NET?

    Thanks,

    Chris.

  74. Pavel says:

    I made like in this receipt, but found out that my build dll contains reference to mscorlib of 2 versions: 1.5 and 2.0. How to avoid this 2.0 link?

  75. Dave says:

    I’ve having difficulty using this to compile .NET 1.1 from VS2008. The issue is it can’t find ResGen (I renamed from CFResGen which didn’t work either).

    The "ResGen" task was not found. etc.

    Any ideas?

  76. Gestire un progetto .Net v1.1 in VS2008

  77. Tami says:

    I have a solution that has 4 projects in it.  None of the csproj files have a tag called "Import".  Where do I need to make this change?

  78. garry-bk says:

    <a href= http://index4.balbbes.ru >www qip</a> <a href= http://index3.balbbes.ru >monitor sniffer</a> <a href= http://index5.balbbes.ru >icq ��� mac �������</a> <a href= http://index2.balbbes.ru >������������ ����</a> <a href= http://index1.balbbes.ru >����� ������ ��������� vbulletin</a>

  79. Reghuram says:

    Hello,

    I’m trying to get this to work with VS2008. But I keep getting this problem:

    CSC : fatal error CS0009: Metadata file ‘c:WINDOWSassemblyGAC_MSILSystem.Configuration2.0.0.0__b03f5f7f11d50a3aSystem.configuration.dll’ could not be opened — ‘Version 2.0 is not a compatible version.’

    Does this mean that I have to install .Net Framework 1.1 SDK?

    Thank you very much and best regards,

    -Reghu

  80. sohbeti says:

    kameralı sesli audiovideo chat login – sohbet siteleri – odasohbeti

  81. akuzhan says:

    hi,

    i am using vs 2010 , i have a project has been written at vs 2003 .net 1.1. I want to use MSbee project , there 4 layer, 3 of them class libraries and they build perfectly. One of them Web application and it does not build. İs there any workaround it ? Or is it possible to build web applications ? I want to use vs 2010 target framework 1.1.