diff -arc3 nant-0.85-rc3.old/src/NAnt.Core/Util/FileUtils.cs nant-0.85-rc3.new/src/NAnt.Core/Util/FileUtils.cs
*** nant-0.85-rc3.old/src/NAnt.Core/Util/FileUtils.cs	Mon Mar 28 13:07:24 2005
--- nant-0.85-rc3.new/src/NAnt.Core/Util/FileUtils.cs	Thu Apr 13 10:33:45 2006
***************
*** 21,26 ****
--- 21,27 ----
  using System.Globalization;
  using System.IO;
  using System.Text;
+ using System.Text.RegularExpressions;
  
  using NAnt.Core.Filters;
  using NAnt.Core.Types;
***************
*** 177,185 ****
--- 178,190 ----
                  throw new ArgumentNullException("path2");
              }
  
+ 
              char separatorChar = Path.DirectorySeparatorChar;
              char[] splitChars = new char[] {'/', separatorChar};
  
+             // Substitute environment variable references in path2
+             path2 = StringUtils.EnvVarSubst( path2 );
+ 
              // Now we split the Path by the Path Separator
              String[] path2Parts = path2.Split(splitChars);
  
***************
*** 199,204 ****
--- 204,220 ----
                  }
              }
  
+             // If path2 is ABSOLUTE (i.e. starts with a drive letter or a
+             // directory separator character) don't prepend path1
+             if (
+              Regex.IsMatch( path2, "^[A-Za-z]:" ) ||
+              path2.StartsWith( "" + Path.DirectorySeparatorChar )
+             ) return path2;
+ 
+ 
+             // Substitute environment variable references in path1
+             path1 = StringUtils.EnvVarSubst( path1 );
+ 
              string[] path1Parts = path1.Split(splitChars);
              int counter = path1Parts.Length;
  
diff -arc3 nant-0.85-rc3.old/src/NAnt.Core/Util/StringUtils.cs nant-0.85-rc3.new/src/NAnt.Core/Util/StringUtils.cs
*** nant-0.85-rc3.old/src/NAnt.Core/Util/StringUtils.cs	Fri Nov 19 09:08:58 2004
--- nant-0.85-rc3.new/src/NAnt.Core/Util/StringUtils.cs	Thu Apr 13 10:30:43 2006
***************
*** 19,24 ****
--- 19,25 ----
  
  using System;
  using System.Collections.Specialized;
+ using System.Text.RegularExpressions;
  
  namespace NAnt.Core.Util {
      /// <summary>
***************
*** 166,171 ****
--- 167,215 ----
              return clone;
          }
  
+ 
+         /// <summary>
+         /// Substitutes environment variable references of the form $(VAR_NAME) with the value
+         /// of environment variable of name "VAR_NAME", or the empty string if no such environment
+         /// variable exists.
+         /// </summary>
+         /// <param name="substString">The <see cref="string" /> in which environment variable substitution
+         /// will take place.</param>
+         /// <returns>
+         /// A new <see cref="string"/>, with all environment variable references replaced by
+         /// corresponding environment variable values.
+         /// </returns>
+         public static String EnvVarSubst(string substString) {
+             return Regex.Replace(
+              substString,
+              @"\$\([A-Za-z_]\w*\)",
+              new MatchEvaluator( SubstEnvVar )
+             );
+         }
          #endregion Public Static Methods
+ 
+ 
+         #region Private Static Methods
+ 
+         /// <summary>
+         /// Helper method for EnvVarSubst method above.
+         /// </summary>
+         /// <param name="m"> <see cref="Match" /> object that contains an environment
+         /// variable reference of the form $(VAR_NAME).</param>
+         /// <returns>
+         /// A new <see cref="string"/> string that is the value of the environment variable
+         /// of name "VAR_NAME", or the empty string if no such environment variable exists.
+         /// </returns>
+          private static string SubstEnvVar(Match m) {
+             // GET THE MATCHED STRING
+             string varRef = m.ToString();
+             // GET RID OF LEADING '$(' AND TRAILING ')'
+             string varName = varRef.Substring( 2, varRef.Length - 3 ).Trim();
+             string varValue = Environment.GetEnvironmentVariable( varName );
+             return varValue == null ? "" : varValue;
+         }
+ 
+         #endregion Private Static Methods
+ 
      }
  }
