From 87eff82b289d42ddddfae0f907c587cab20edbfe Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 13 Jan 2009 10:06:53 +0000 Subject: * Added resolving explicit .exe project names. This fixes mantis #2967 --- Prebuild/src/Core/Targets/NAntTarget.cs | 58 ++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 8 deletions(-) (limited to 'Prebuild') diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs index 2e06a50..b64c57e 100644 --- a/Prebuild/src/Core/Targets/NAntTarget.cs +++ b/Prebuild/src/Core/Targets/NAntTarget.cs @@ -92,27 +92,62 @@ namespace Prebuild.Core.Targets private static string BuildReference(SolutionNode solution, ProjectNode currentProject, ReferenceNode refr) { string ret = ""; + string referencePath = ((ReferencePathNode)currentProject.ReferencePaths[0]).Path; + if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; - string finalPath = Helper.NormalizePath(((ReferencePathNode)currentProject.ReferencePaths[0]).Path + refr.Name + GetProjectExtension(project), '/'); + string finalPath = Helper.NormalizePath(referencePath + refr.Name + GetProjectExtension(project), '/'); return finalPath; } else { - ProjectNode project = (ProjectNode)refr.Parent; + if (refr.Name == "Pootface.exe") + { + Console.WriteLine("Poot!"); + } + + ProjectNode project = (ProjectNode) refr.Parent; + + // Do we have an explicit file reference? string fileRef = FindFileReference(refr.Name, project); + if( fileRef != null ) + { + return fileRef; + } - if (refr.Path != null || fileRef != null) + // Is there an explicit path in the project ref? + if (refr.Path != null) { - string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/') : fileRef; - ret += finalPath; - return ret; + return Helper.NormalizePath( refr.Path + "/" + refr.Name + GetProjectExtension(project), '/'); + } + + // Is it a specified extension (dll or exe?) + if (ExtensionSpecified(refr.Name)) + { + return Helper.NormalizePath( referencePath + GetRefFileName(refr.Name), '/'); } - ret += (refr.Name + ".dll"); + // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway + return refr.Name + ".dll"; } - return ret; + } + + public static string GetRefFileName(string refName) + { + if (ExtensionSpecified(refName)) + { + return refName; + } + else + { + return refName + ".dll"; + } + } + + private static bool ExtensionSpecified(string refName) + { + return refName.EndsWith(".dll") || refName.EndsWith(".exe"); } private static string GetProjectExtension(ProjectNode project) @@ -177,6 +212,13 @@ namespace Prebuild.Core.Targets { return fullPath; } + + fullPath = Helper.MakeFilePath(refPath.Path, refName, "exe"); + + if (File.Exists(fullPath)) + { + return fullPath; + } } return null; -- cgit v1.1