From 55d89b73edbfc12da6f6ec11c6f1aa429a7e7a40 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 17 Feb 2009 16:15:29 +0000 Subject: * fixed 'path' reference attribute for Nant and VS2008 targets. --- Prebuild/src/Core/Targets/NAntTarget.cs | 148 ++++++++++++++++-------------- Prebuild/src/Core/Targets/VS2005Target.cs | 30 +++++- 2 files changed, 105 insertions(+), 73 deletions(-) (limited to 'Prebuild/src/Core/Targets') diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs index b64c57e..eb5325d 100644 --- a/Prebuild/src/Core/Targets/NAntTarget.cs +++ b/Prebuild/src/Core/Targets/NAntTarget.cs @@ -94,42 +94,45 @@ namespace Prebuild.Core.Targets string ret = ""; string referencePath = ((ReferencePathNode)currentProject.ReferencePaths[0]).Path; - if (solution.ProjectsTable.ContainsKey(refr.Name)) + if (String.IsNullOrEmpty(refr.Path)) { - ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; - string finalPath = Helper.NormalizePath(referencePath + refr.Name + GetProjectExtension(project), '/'); - return finalPath; - } - else - { - if (refr.Name == "Pootface.exe") + if (solution.ProjectsTable.ContainsKey(refr.Name)) { - Console.WriteLine("Poot!"); + ProjectNode project = (ProjectNode) solution.ProjectsTable[refr.Name]; + string finalPath = + Helper.NormalizePath(referencePath + refr.Name + GetProjectExtension(project), '/'); + return finalPath; } + else + { + ProjectNode project = (ProjectNode) refr.Parent; - ProjectNode project = (ProjectNode) refr.Parent; + // Do we have an explicit file reference? + string fileRef = FindFileReference(refr.Name, project); + if (fileRef != null) + { + return fileRef; + } - // Do we have an explicit file reference? - string fileRef = FindFileReference(refr.Name, project); - if( fileRef != null ) - { - return fileRef; - } + // Is there an explicit path in the project ref? + if (refr.Path != null) + { + return Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/'); + } - // Is there an explicit path in the project ref? - if (refr.Path != null) - { - 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), '/'); + } - // Is it a specified extension (dll or exe?) - if (ExtensionSpecified(refr.Name)) - { - return Helper.NormalizePath( referencePath + GetRefFileName(refr.Name), '/'); + // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway + return refr.Name + ".dll"; } - - // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway - return refr.Name + ".dll"; + } + else + { + return refr.Path; } } @@ -160,47 +163,54 @@ namespace Prebuild.Core.Targets return extension; } - private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) - { - string ret = ""; - if (solution.ProjectsTable.ContainsKey(refr.Name)) - { - ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; - string finalPath = Helper.NormalizePath(((ReferencePathNode)project.ReferencePaths[0]).Path, '/'); - return finalPath; - } - else - { - ProjectNode project = (ProjectNode)refr.Parent; - string fileRef = FindFileReference(refr.Name, project); - - if (refr.Path != null || fileRef != null) - { - string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; - ret += finalPath; - return ret; - } - - try - { - Assembly assem = Assembly.Load(refr.Name); - if (assem != null) - { - ret += ""; - } - else - { - ret += ""; - } - } - catch (System.NullReferenceException e) - { - e.ToString(); - ret += ""; - } - } - return ret; - } + //private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) + //{ + // string ret = ""; + // if (solution.ProjectsTable.ContainsKey(refr.Name)) + // { + // ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; + // string finalPath = Helper.NormalizePath(((ReferencePathNode)project.ReferencePaths[0]).Path, '/'); + // return finalPath; + // } + // else + // { + // if (refr.Path == null) + // { + // ProjectNode project = (ProjectNode) refr.Parent; + // string fileRef = FindFileReference(refr.Name, project); + + // if (refr.Path != null || fileRef != null) + // { + // string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; + // ret += finalPath; + // return ret; + // } + + // try + // { + // Assembly assem = Assembly.Load(refr.Name); + // if (assem != null) + // { + // ret += ""; + // } + // else + // { + // ret += ""; + // } + // } + // catch (System.NullReferenceException e) + // { + // e.ToString(); + // ret += ""; + // } + // } + // else + // { + // ret = refr.Path; + // } + // } + // return ret; + //} private static string FindFileReference(string refName, ProjectNode project) { diff --git a/Prebuild/src/Core/Targets/VS2005Target.cs b/Prebuild/src/Core/Targets/VS2005Target.cs index 8e09711..5b7ad07 100644 --- a/Prebuild/src/Core/Targets/VS2005Target.cs +++ b/Prebuild/src/Core/Targets/VS2005Target.cs @@ -364,6 +364,21 @@ namespace Prebuild.Core.Targets return ret; } + private static bool ExtensionSpecified(string refName) + { + return refName.EndsWith(".dll") || refName.EndsWith(".exe"); + } + + private static string GetProjectExtension(ProjectNode project) + { + string extension = ".dll"; + if (project.Type == ProjectType.Exe) + { + extension = ".exe"; + } + return extension; + } + private void WriteProject(SolutionNode solution, ProjectNode project) { if (!tools.ContainsKey(project.Language)) @@ -474,14 +489,21 @@ namespace Prebuild.Core.Targets ps.WriteLine("\" >"); string path; - - if (refr.Name.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase)) + + if (String.IsNullOrEmpty(refr.Path)) { - path = Helper.NormalizePath(Path.Combine( refPath, refr.Name), '\\'); + if ( ExtensionSpecified( refr.Name ) ) + { + path = Helper.NormalizePath(Path.Combine(refPath, refr.Name), '\\'); + } + else + { + path = refr.Name + ".dll"; + } } else { - path = refr.Name + ".dll"; + path = refr.Path; } // TODO: Allow reference to *.exe files -- cgit v1.1