diff options
Diffstat (limited to 'Prebuild')
-rw-r--r-- | Prebuild/src/Core/Targets/NAntTarget.cs | 148 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/VS2005Target.cs | 30 |
2 files changed, 105 insertions, 73 deletions
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 | |||
94 | string ret = ""; | 94 | string ret = ""; |
95 | string referencePath = ((ReferencePathNode)currentProject.ReferencePaths[0]).Path; | 95 | string referencePath = ((ReferencePathNode)currentProject.ReferencePaths[0]).Path; |
96 | 96 | ||
97 | if (solution.ProjectsTable.ContainsKey(refr.Name)) | 97 | if (String.IsNullOrEmpty(refr.Path)) |
98 | { | 98 | { |
99 | ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; | 99 | if (solution.ProjectsTable.ContainsKey(refr.Name)) |
100 | string finalPath = Helper.NormalizePath(referencePath + refr.Name + GetProjectExtension(project), '/'); | ||
101 | return finalPath; | ||
102 | } | ||
103 | else | ||
104 | { | ||
105 | if (refr.Name == "Pootface.exe") | ||
106 | { | 100 | { |
107 | Console.WriteLine("Poot!"); | 101 | ProjectNode project = (ProjectNode) solution.ProjectsTable[refr.Name]; |
102 | string finalPath = | ||
103 | Helper.NormalizePath(referencePath + refr.Name + GetProjectExtension(project), '/'); | ||
104 | return finalPath; | ||
108 | } | 105 | } |
106 | else | ||
107 | { | ||
108 | ProjectNode project = (ProjectNode) refr.Parent; | ||
109 | 109 | ||
110 | ProjectNode project = (ProjectNode) refr.Parent; | 110 | // Do we have an explicit file reference? |
111 | string fileRef = FindFileReference(refr.Name, project); | ||
112 | if (fileRef != null) | ||
113 | { | ||
114 | return fileRef; | ||
115 | } | ||
111 | 116 | ||
112 | // Do we have an explicit file reference? | 117 | // Is there an explicit path in the project ref? |
113 | string fileRef = FindFileReference(refr.Name, project); | 118 | if (refr.Path != null) |
114 | if( fileRef != null ) | 119 | { |
115 | { | 120 | return Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/'); |
116 | return fileRef; | 121 | } |
117 | } | ||
118 | 122 | ||
119 | // Is there an explicit path in the project ref? | 123 | // Is it a specified extension (dll or exe?) |
120 | if (refr.Path != null) | 124 | if (ExtensionSpecified(refr.Name)) |
121 | { | 125 | { |
122 | return Helper.NormalizePath( refr.Path + "/" + refr.Name + GetProjectExtension(project), '/'); | 126 | return Helper.NormalizePath(referencePath + GetRefFileName(refr.Name), '/'); |
123 | } | 127 | } |
124 | 128 | ||
125 | // Is it a specified extension (dll or exe?) | 129 | // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway |
126 | if (ExtensionSpecified(refr.Name)) | 130 | return refr.Name + ".dll"; |
127 | { | ||
128 | return Helper.NormalizePath( referencePath + GetRefFileName(refr.Name), '/'); | ||
129 | } | 131 | } |
130 | 132 | } | |
131 | // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway | 133 | else |
132 | return refr.Name + ".dll"; | 134 | { |
135 | return refr.Path; | ||
133 | } | 136 | } |
134 | } | 137 | } |
135 | 138 | ||
@@ -160,47 +163,54 @@ namespace Prebuild.Core.Targets | |||
160 | return extension; | 163 | return extension; |
161 | } | 164 | } |
162 | 165 | ||
163 | private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) | 166 | //private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) |
164 | { | 167 | //{ |
165 | string ret = ""; | 168 | // string ret = ""; |
166 | if (solution.ProjectsTable.ContainsKey(refr.Name)) | 169 | // if (solution.ProjectsTable.ContainsKey(refr.Name)) |
167 | { | 170 | // { |
168 | ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; | 171 | // ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; |
169 | string finalPath = Helper.NormalizePath(((ReferencePathNode)project.ReferencePaths[0]).Path, '/'); | 172 | // string finalPath = Helper.NormalizePath(((ReferencePathNode)project.ReferencePaths[0]).Path, '/'); |
170 | return finalPath; | 173 | // return finalPath; |
171 | } | 174 | // } |
172 | else | 175 | // else |
173 | { | 176 | // { |
174 | ProjectNode project = (ProjectNode)refr.Parent; | 177 | // if (refr.Path == null) |
175 | string fileRef = FindFileReference(refr.Name, project); | 178 | // { |
176 | 179 | // ProjectNode project = (ProjectNode) refr.Parent; | |
177 | if (refr.Path != null || fileRef != null) | 180 | // string fileRef = FindFileReference(refr.Name, project); |
178 | { | 181 | |
179 | string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; | 182 | // if (refr.Path != null || fileRef != null) |
180 | ret += finalPath; | 183 | // { |
181 | return ret; | 184 | // string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; |
182 | } | 185 | // ret += finalPath; |
183 | 186 | // return ret; | |
184 | try | 187 | // } |
185 | { | 188 | |
186 | Assembly assem = Assembly.Load(refr.Name); | 189 | // try |
187 | if (assem != null) | 190 | // { |
188 | { | 191 | // Assembly assem = Assembly.Load(refr.Name); |
189 | ret += ""; | 192 | // if (assem != null) |
190 | } | 193 | // { |
191 | else | 194 | // ret += ""; |
192 | { | 195 | // } |
193 | ret += ""; | 196 | // else |
194 | } | 197 | // { |
195 | } | 198 | // ret += ""; |
196 | catch (System.NullReferenceException e) | 199 | // } |
197 | { | 200 | // } |
198 | e.ToString(); | 201 | // catch (System.NullReferenceException e) |
199 | ret += ""; | 202 | // { |
200 | } | 203 | // e.ToString(); |
201 | } | 204 | // ret += ""; |
202 | return ret; | 205 | // } |
203 | } | 206 | // } |
207 | // else | ||
208 | // { | ||
209 | // ret = refr.Path; | ||
210 | // } | ||
211 | // } | ||
212 | // return ret; | ||
213 | //} | ||
204 | 214 | ||
205 | private static string FindFileReference(string refName, ProjectNode project) | 215 | private static string FindFileReference(string refName, ProjectNode project) |
206 | { | 216 | { |
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 | |||
364 | return ret; | 364 | return ret; |
365 | } | 365 | } |
366 | 366 | ||
367 | private static bool ExtensionSpecified(string refName) | ||
368 | { | ||
369 | return refName.EndsWith(".dll") || refName.EndsWith(".exe"); | ||
370 | } | ||
371 | |||
372 | private static string GetProjectExtension(ProjectNode project) | ||
373 | { | ||
374 | string extension = ".dll"; | ||
375 | if (project.Type == ProjectType.Exe) | ||
376 | { | ||
377 | extension = ".exe"; | ||
378 | } | ||
379 | return extension; | ||
380 | } | ||
381 | |||
367 | private void WriteProject(SolutionNode solution, ProjectNode project) | 382 | private void WriteProject(SolutionNode solution, ProjectNode project) |
368 | { | 383 | { |
369 | if (!tools.ContainsKey(project.Language)) | 384 | if (!tools.ContainsKey(project.Language)) |
@@ -474,14 +489,21 @@ namespace Prebuild.Core.Targets | |||
474 | ps.WriteLine("\" >"); | 489 | ps.WriteLine("\" >"); |
475 | 490 | ||
476 | string path; | 491 | string path; |
477 | 492 | ||
478 | if (refr.Name.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase)) | 493 | if (String.IsNullOrEmpty(refr.Path)) |
479 | { | 494 | { |
480 | path = Helper.NormalizePath(Path.Combine( refPath, refr.Name), '\\'); | 495 | if ( ExtensionSpecified( refr.Name ) ) |
496 | { | ||
497 | path = Helper.NormalizePath(Path.Combine(refPath, refr.Name), '\\'); | ||
498 | } | ||
499 | else | ||
500 | { | ||
501 | path = refr.Name + ".dll"; | ||
502 | } | ||
481 | } | 503 | } |
482 | else | 504 | else |
483 | { | 505 | { |
484 | path = refr.Name + ".dll"; | 506 | path = refr.Path; |
485 | } | 507 | } |
486 | 508 | ||
487 | // TODO: Allow reference to *.exe files | 509 | // TODO: Allow reference to *.exe files |