Welcome to MSDN Blogs Sign in | Join | Help

Hack the Build: Targetting .NET Runtime 1.1 Step-by-Step

Note: This article is about targetting CLR version 1.1 with Whidbey Beta1. If you're interested in Beta2 see this article.

 

Jomo Fisher--MSBuild doesn't ship with a way to target CLR version 1.1. I discussed the reasons for this in a prior blog entry and I even said that I respected the decision given our resource limitations. On the other hand, respecting something and living with it is not the same thing so I decided to see exactly what it would take to target an older CLR.

 

My criteria were modest:

- I want reuse most of the existing build logic that ships with MSBuild. After all, this blog is about hacking the build, and throwing everything away and starting over didn’t seem in the spirit of things. (Plus it would be hard and I’m lazy).

- I wanted to build both Whidbey and CLR 1.1 binaries at the same time (in the same build gesture).

- I wanted to be able to compile at least minimal console applications, window applications and libraries.

- I wanted to keep Intellisense working and reflecting latest Whidbey libraries.

- I wanted to be able to call library code in other projects in the solution.

- I was willing to live with only C# support (at least for now).

- I didn't care too much about optimal rebuild or clean support (at least for now).

 

What I ended up is a .targets file that meets my goals and that you can use as a sample for how to target multiple platforms with MSBuild. Here are the steps for Whidbey Beta 1:

(1)   Copy this sample into a file called C:\MyTargets\CSharp.SideBySide.Targets

(2)   Create a new C# console application called MyApp.

(3)   Build and see that there are no errors or warnings.

(4)   Open up MyApp.csproj in notepad and replace the import tag near the bottom with,

  <Import Project=" C:\MyTargets\CSharp.SideBySide.Targets" />

(5)   Save and exit from notepad.

(6)   Return to VS and press “Reload” when prompted.

(7)   Now “Rebuild” the console application.

 

At this point, if the build fails with a message like,

 

Properties\Settings.cs(13,9): error CS1518: Expected class, delegate, enum, interface, or struct

 

Then it’s working. This error is because the CLR 1.1 C# compiler doesn’t support partial classes. To get past this, you’ll need to delete the Settings.cs file. In the Solution Explorer click “Show All Files”. Now, in the Solution explorer you should see an entry called Settings.settings. Delete it and rebuild the project again.

 

At this point, the build should fail again with a message like,

 

Program.cs(4,26): error CS0234: The type or namespace name 'Generic' does not exist in the class or namespace 'System.Collections' (are you missing an assembly reference?)

 

This is because the old compiler didn’t support generics.  You’ll need to delete this line,

 

using System.Collections.Generic;

 

from Program.cs and then build again. (As you can see, there are plenty of neat new features in the new compiler that you won't be able to use if you want to target the older framework.)

 

This latest build should succeed, and you should now have a bin directory that looks like this (in part):

 

 bin\Debug\ConsoleApplication1.exe

 bin\Debug(1.1)\ConsoleApplication1.exe

 

The first is the plain old Whidbey application. The second is a version that will run under the CLR version 1.1.

 

Please keep in mind that only the very basic scenarios have a chance of working. For example, I’m pretty confident that COM references are completely broken. If you try these targets out, let me know what you have problems with. If I can see a cheap, hack-the-build-worthy solution I’ll update the sample as I have the time.

 

Whidbey still won't ship with a way to target the 1.1 CLR but at least now there's starting point for doing it yourself.

 

In future entries, I will take apart the sample and explain how the various hacks pieces work.

 

[Update December 16, 2004 --Jomo Fisher

Check out another community effort to target the 1.1 FX.

http://mark.michaelis.net/Blog/PermaLink.aspx?guid=a2aa1af7-e71e-4296-81fe-7bcecbb7a9cd]

 

[Update October 8, 2004 --Jomo Fisher

It looks like there's a chance that target names with dots in them will be illegal starting with Beta2. I've updated the sample, but if you're using the prior version, you may want to get the latest to avoid being broken down the road.]

 

[Update October 5, 2004 --Jomo Fisher

Looks like there's a similar effort going on at Test Driven .NET. This one actually creates a replacement for MSBuild.exe. Very cool. Here's the link:

http://weblogs.asp.net/nunitaddin/archive/2004/10/05/238009.aspx]

 

[Update October 3, 2004 --Jomo Fisher

What a difference a day makes. Robert McClaws saw my Hack the Build: Targetting .NET Runtime 1.1 Step-by-Step article from Friday and identified several ways to make it better. He wanted to target the 1.0 CLR, he wanted VB support, he wanted more flexible choices over where outputs go. In other words, he wanted the build that *he* wanted, and that's what MSBuild is all about.

 

From his posting,

 

"So I spent the past 24 hours (practically straight) working on making everything work the way I wanted. The result is the MSBuild Compatibility Toolkit, a clean, standardized system for extending .NET Framework compilation support, with or without Visual Studio 2005."

 

I haven't looked at his stuff, but it looks like it has a nice installer MSI and (if my reading of his post is correct) he's made templates for creating new projects.

 

You can check his stuff out here.]

  

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

 

 

 

Published Friday, October 01, 2004 8:31 PM by Jomo Fisher

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Hack the Build: An Introduction

Saturday, October 02, 2004 3:45 PM by Hack the Build: Ramblings of an MSBuild Developer

# re: Visual Studio 2005 Build Compatibility

Sunday, October 03, 2004 6:27 AM by Robert McLaws: FunWithCoding.NET

# re: Visual Studio 2005 Build Compatibility

Sunday, October 03, 2004 6:36 AM by Robert McLaws: FunWithCoding.NET

# Announcing the MSBuild Compatibility Toolkit 1.0

Sunday, October 03, 2004 8:20 AM by Robert McLaws: FunWithCoding.NET

# Announcing the MSBuild Compatibility Toolkit 1.0

Sunday, October 03, 2004 8:22 AM by Robert McLaws: FunWithCoding.NET

# everyone wants it...

Sunday, October 03, 2004 5:43 PM by jeffcal's blogland

# everyone wants it...

Sunday, October 03, 2004 5:47 PM by jeffcal's blogland

# re: Hack the Build: Targetting .NET Runtime 1.1 Step-by-Step

There is an open suggestion with 61 votes, currently all-time #11, on this issue:

http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=15986521-ee6a-4397-8937-1b9cee7f2cf1

Given the amount of interest in this, I would strongly suggest that the MSBuild team re-think their priorities. One other major reason is VSTS support. If companies are to migrate over to VSTS, using VS2003 is not even an option as the client requires 2005.
Sunday, October 03, 2004 6:55 PM by Oren Novotny

# Announcing the MSBuild Compatibility Toolkit 1.0(ZT)

TrackBack From:http://www.cnblogs.com/ccboy/archive/2004/10/09/50326.aspx
Saturday, October 09, 2004 9:40 AM by ccBoy

# Announcing the MSBuild Compatibility Toolkit 1.0

Monday, October 11, 2004 3:46 PM by Robert McLaws: FunWithCoding.NET

# Bugs introduced

Line 55 should be: <br>&lt;CreateItem <br> Include=&quot;@(FrameworkReferencePath-&gt;'$(SystemRoot)\Microsoft.NET\Framework\v1.1.4322\%(FileName)%(Extension)')&quot;&gt; <br> &lt;Output TaskParameter=&quot;Include&quot; ItemName=&quot;AssemblyReferencePaths11&quot; /&gt; <br> &lt;/CreateItem&gt; <br> <br>Otherwise it will not find references :) <br>Another thing is that this target does not include external references (not a system ones). Could someone fix it - cause i do not know how :D
Sunday, October 17, 2004 6:39 PM by Alenas

# re: Does not include external references

I made mistake - I was referencing 2.0 assembly - that's why it was not included.
Sunday, October 17, 2004 7:10 PM by Alenas

# re: Hack the Build: Targetting .NET Runtime 1.1 Step-by-Step

Glad you liked! I was hoping you wouldn't be mad. Thanks for the "dots" update. I'll be looking at the changes in the CTP that goes out next week and modifying accordingly. Any chance that you know how to programmatically access the Project's targets references?
Monday, October 18, 2004 3:02 AM by Robert McLaws

# SDC Build Tools and 1.0?

Wednesday, November 10, 2004 3:59 AM by Andrew Stopford's Weblog

# partial solution to my problem

Monday, December 13, 2004 8:04 PM by who IS jake?

# partial solution to my problem

Monday, December 13, 2004 8:05 PM by who IS jake?

# Tiernans Blog &raquo; Target .NET 1.1 with MSBuild

Tiernans Blog &raquo; Target .NET 1.1 with MSBuild
Saturday, January 01, 2005 7:36 PM by TrackBack

# MSBuild for .NET 1.1

I'm currently trying to find a way of building .NET apps for .NET 1.1 using MSBuild.&amp;nbsp; Not entirely...
Thursday, April 07, 2005 7:56 AM by Life, Universe and Everything according to Dirk

# re: Need Help for MSBuild on .NET 1.1

Thursday, April 21, 2005 4:21 AM by Robert McLaws: FunWithCoding.NET

# 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 with MSBuild....
Friday, April 22, 2005 2:48 PM by Hack the Build: Adventures in MSBuild

# Announcing the MSBuild Toolkit for Visual Studio 2005 RC!

Friday, June 03, 2005 11:55 PM by Robert McLaws: FunWithCoding.NET

# re: Hack the Build: Targetting .NET Runtime 1.1 Step-by-Step

may i Targetting .NET Runtime 1.1 for c++ managed extentions?
thanks
Tuesday, January 03, 2006 10:11 AM by michael

# VSTS Jumpstart, things you will end up asking for

The following is my official VSTS jumpstart kit.&amp;nbsp; I will maintain this post entry going forward....
Wednesday, February 08, 2006 11:13 AM by Clark Sell

# VSTS Jumpstart, things you will end up asking for

Internet Links
Visual Studio Team System Home
Getting Started with Team Foundation
MSDN Technical...
Wednesday, February 08, 2006 10:18 PM by Clark Sell

# Building .NET 1.1 application using Team Build

One of the FAQs in Team Foundation forums have been on &quot;how to build .NET 1.1 application using Team...
Wednesday, April 19, 2006 8:05 AM by Gautam Goenka (MSFT)

# VSTS Jumpstart, things you will end up asking for

Internet Links Visual Studio Team System Home Getting Started with Team Foundation MSDN Technical Forums

Wednesday, October 25, 2006 10:13 PM by Clark Sell

# VS 2002 / 2003 / 2005 Conversions and Building

The following are some different resources to either convert your Visual Studio 2002/2003 projects to

Wednesday, October 25, 2006 10:14 PM by Clark Sell

# Good site

Excellent browsing have the to

Monday, December 11, 2006 7:42 PM by incid

# Good site

Excellent browsing have the to

Wednesday, December 13, 2006 12:51 PM by fisso

# hello

Very interesting.,Very interesting.

Thursday, December 21, 2006 12:12 PM by ware,ware

# hello

Very interesting.,Very interesting.

Saturday, December 23, 2006 11:59 PM by sarde,sarde

# Crad,Good site

Hi!

<a href= thanks for sharing ></a>   [url=thanks for sharing][/url]  

Monday, February 12, 2007 11:53 AM by Crad

# Crad,Good site

Hi!

<a href= thanks for sharing ></a>   [url=thanks for sharing][/url]  

Monday, February 12, 2007 11:53 AM by Crad

# Crad,Good site

Hi!

<a href= thanks for sharing ></a>   [url=thanks for sharing][/url]  

Monday, February 12, 2007 8:06 PM by Crad

# Vasya,Good site

Hi!

<a href= b52156c8aac1434d38838ef84dfbd701

></a>   [url=b52156c8aac1434d38838ef84dfbd701

][/url]  

Friday, February 16, 2007 4:42 AM by Vasya

# Oregon,Good site

Hi!

<a href= 459320b57da587f577b1d5efbb5947c8

></a>   [url=459320b57da587f577b1d5efbb5947c8

][/url]  

Friday, February 16, 2007 6:05 AM by Oregon

# Orcas Multi-targeting - Feature Complete

I intended to post about this a couple of months ago and am finally getting around to it. Good news though

Friday, August 10, 2007 4:57 AM by .. ance() where T : Foo, new() {

# Orcas Multi-targeting - Feature Complete

I intended to post about this a couple of months ago and am finally getting around to it. Good news though

Friday, August 10, 2007 4:58 AM by .. ance() where T : Foo, new() {

# Orcas Multi-targeting - Feature Complete

I intended to post about this a couple of months ago and am finally getting around to it. ...

Friday, August 10, 2007 4:58 AM by .. ance<T>() where T : Foo, new() {

# Orcas Multi-targeting - Feature Complete

I intended to post about this a couple of months ago and am finally getting around to it. ...

Sunday, August 12, 2007 2:12 AM by .. ance<T>() where T : Foo, new() {

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

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

Friday, August 22, 2008 10:06 AM by Lazy Developer

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

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

Friday, August 22, 2008 11:05 AM by Community Blogs

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker