Firstly I noticed that the patch failed when you specified patterns instead of filenames eg "*.dll".

Then I thought about it and decided that fileset isn't necessarily the best place to be doing this. The only time that fromframework really needs to be inferred is from the compiler tasks.

So I went and made a change to compilerbase so that it checks the Includes collection of the references fileset and for every item that looks like a filename only ( ie no path information ) I test to see if a file of that name exists in the framework dir and if so add it to the references collection.
The advantage with this way of doing it is that you don't need the extra "fromframework" attribute. It just works.


I also handle the case where you happen to have a file named the same as a system assembly in your local directory - ie I'll use the local one in that case.

I've attached the patch. Let me know what you think.

This also means that vbc compilation will be much nicer since vbc doesn't use the response file and until now you have to specify the full path to framework assemblies.

Ian

I'll wait until we've had some comments (regarding the same of the
attribute, and ...) from other members of the community before committing it
...

Thanks !

Gert

----- Original Message ----- From: "Jaroslaw Kowalski" <[EMAIL PROTECTED]>
To: "NAnt Developers" <[EMAIL PROTECTED]>
Sent: Saturday, September 06, 2003 6:38 PM
Subject: [nant-dev] [PATCH] New fileset option "fromframework"





Hi!

Attached is a patch that adds "fromframework" feature to all filesets.

When you include a file with fromframework="true" its full name will be
determined by Path.Combining it with current framework's assembly


directory.


This is useful for compilation of .NET CF programs where you need to


specify


your own corlib and System.dll paths.

This also helps you get rid of:

<includes name="System.Data.dll" asis="true" />

which relies on csc.exe being able to find its own framework assemblies.
When fromframework="true" is used, csc is given the fully qualified path
name where the assemblies reside and doesn't have to do any "guessing".

Basically, when you replace asis="true" with fromframework="true" in
references to system assemblies, your project should remain correct, yet


it


would get the ability to be buildable for .NET CF.

Can someone review it and apply to CVS ? The patch was made against a


fresh


anonymous CVS checkout.

Jarek

BTW. If someone can invent any better name (than fromframework), feel free
to change it.






-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



Index: src/NAnt.DotNet/Tasks/CompilerBase.cs
===================================================================
RCS file: /cvsroot/nant/nant/src/NAnt.DotNet/Tasks/CompilerBase.cs,v
retrieving revision 1.34
diff -u -r1.34 CompilerBase.cs
--- src/NAnt.DotNet/Tasks/CompilerBase.cs       31 Aug 2003 12:06:24 -0000      1.34
+++ src/NAnt.DotNet/Tasks/CompilerBase.cs       7 Sep 2003 17:17:13 -0000
@@ -296,7 +296,20 @@
                     if (this.WarnAsError) {
                         WriteOption(writer, "warnaserror");
                     }
-
+                    // check for framework references
+                    foreach ( string pattern in References.Includes ) {
+                        
+                        if ( Path.GetFileName( pattern ) == pattern ) {
+                            string frameworkDir = 
Project.CurrentFramework.FrameworkAssemblyDirectory.FullName;
+                            string localPath = Path.Combine( 
References.BaseDirectory, pattern);
+                            string fullPath = Path.Combine(frameworkDir, pattern);
+                            
+                            if (! File.Exists( localPath ) && File.Exists(  fullPath 
)) {
+                                // found a system reference
+                                References.FileNames.Add( fullPath );
+                            }
+                        }
+                    }
                     foreach (string fileName in References.FileNames) {
                         WriteOption(writer, "reference", fileName);
                     }

Reply via email to