Browse files

Update ScriptCompilerExecTask as well for include support

  • Loading branch information...
1 parent 7f183fa commit 374ae2a3332a0ca77a2a64d6ce824ba0b1ef20a7 @nikhilk committed Dec 20, 2012
Showing with 17 additions and 1 deletion.
  1. +17 −1 src/Core/Build/Tasks/ScriptCompilerExecTask.cs
View
18 src/Core/Build/Tasks/ScriptCompilerExecTask.cs
@@ -19,7 +19,7 @@ namespace ScriptSharp.Tasks {
/// The Script# MSBuild task corresponding exactly to functionality exposed
/// by the command-line tool.
/// </summary>
- public sealed class ScriptCompilerExecTask : Task, IErrorHandler {
+ public sealed class ScriptCompilerExecTask : Task, IErrorHandler, IStreamSourceResolver {
private string _projectPath;
private ITaskItem[] _references;
@@ -144,6 +144,7 @@ public sealed class ScriptCompilerExecTask : Task, IErrorHandler {
options.References = GetReferences();
options.Sources = GetSources(_sources);
options.Resources = GetResources(_resources);
+ options.IncludeResolver = this;
ITaskItem scriptTaskItem = new TaskItem(OutputPath);
options.ScriptFile = new TaskItemOutputStreamSource(scriptTaskItem);
@@ -284,6 +285,21 @@ public sealed class ScriptCompilerExecTask : Task, IErrorHandler {
}
#endregion
+ #region Implementation of IStreamSourceResolver
+
+ IStreamSource IStreamSourceResolver.Resolve(string name) {
+ if (_projectPath != null) {
+ string path = Path.Combine(Path.GetDirectoryName(_projectPath), name);
+ if (File.Exists(path)) {
+ return new FileInputStreamSource(path, name);
+ }
+ }
+
+ return null;
+ }
+
+ #endregion
+
private sealed class TaskItemInputStreamSource : FileInputStreamSource {

0 comments on commit 374ae2a

Please sign in to comment.