diff --git a/Readme.md b/Readme.md
index 1442baf..4f17eb8 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,3 +1,14 @@
+Please note: it's been a while since a Scripty release. I'm not entirely sure when (or if) development on this project will resume. While I would love to pick up development here again at some point, I don't know if it makes sense to dedicate any more time given that the Roslyn team has committed to ship [source generators](https://github.com/dotnet/roslyn/projects/54) as part of .NET 5.
+
+In the meantime some other projects in this area include:
+
+- [CodeGeneration.Roslyn](https://github.com/aarnott/CodeGeneration.Roslyn)
+- [Uno.CodeGen](https://github.com/unoplatform/Uno.CodeGen)
+
+Also note that the Scripty Visual Studio extension has been removed from the Visual Studio Extension Gallery due to reports of incompatibilities with the most recent versions of Visual Studio. It will be replaced when the next release comes out, but in the meantime you can download it directly from the [GitHub version 0.7.4 release page](https://github.com/daveaglick/Scripty/releases/tag/v0.7.4).
+
+---
+
Tools to let you use Roslyn-powered C# scripts for code generation. You can think of it as a scripted alternative to T4 templates.
**Note that this document corresponds to the currently active source code branch, which may be in development. To view documentation for the latest *release* of Scripty make sure you are viewing the `master` branch.**
diff --git a/src/Cake.Scripty.Tests/Cake.Scripty.Tests.csproj b/src/Cake.Scripty.Tests/Cake.Scripty.Tests.csproj
index 17c3f21..bf358e8 100644
--- a/src/Cake.Scripty.Tests/Cake.Scripty.Tests.csproj
+++ b/src/Cake.Scripty.Tests/Cake.Scripty.Tests.csproj
@@ -8,7 +8,7 @@
Properties
Cake.Scripty.Tests
Cake.Scripty.Tests
- v4.5
+ v4.6
512
{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10.0
@@ -36,13 +36,11 @@
4
-
- ..\packages\Cake.Core.0.17.0\lib\net45\Cake.Core.dll
- True
+
+ ..\packages\Cake.Core.0.22.0\lib\net46\Cake.Core.dll
-
- ..\packages\Cake.Testing.0.17.1\lib\net45\Cake.Testing.dll
- True
+
+ ..\packages\Cake.Testing.0.22.0\lib\net46\Cake.Testing.dll
..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll
diff --git a/src/Cake.Scripty.Tests/packages.config b/src/Cake.Scripty.Tests/packages.config
index 44689aa..adc1b1e 100644
--- a/src/Cake.Scripty.Tests/packages.config
+++ b/src/Cake.Scripty.Tests/packages.config
@@ -1,6 +1,6 @@
-
-
+
+
\ No newline at end of file
diff --git a/src/Cake.Scripty/Cake.Scripty.csproj b/src/Cake.Scripty/Cake.Scripty.csproj
index 58844de..34e9658 100644
--- a/src/Cake.Scripty/Cake.Scripty.csproj
+++ b/src/Cake.Scripty/Cake.Scripty.csproj
@@ -9,7 +9,7 @@
Properties
Cake.Scripty
Cake.Scripty
- v4.5
+ v4.6
512
@@ -33,9 +33,8 @@
Cake.Scripty.xml
-
- ..\packages\Cake.Core.0.17.0\lib\net45\Cake.Core.dll
- True
+
+ ..\packages\Cake.Core.0.22.0\lib\net46\Cake.Core.dll
diff --git a/src/Cake.Scripty/packages.config b/src/Cake.Scripty/packages.config
index 97366f9..add9fc7 100644
--- a/src/Cake.Scripty/packages.config
+++ b/src/Cake.Scripty/packages.config
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/src/Scripty.Core.Tests/Resolvers/InterceptDirectiveResolverTests.cs b/src/Scripty.Core.Tests/Resolvers/InterceptDirectiveResolverTests.cs
index d5bc587..255fa06 100644
--- a/src/Scripty.Core.Tests/Resolvers/InterceptDirectiveResolverTests.cs
+++ b/src/Scripty.Core.Tests/Resolvers/InterceptDirectiveResolverTests.cs
@@ -212,7 +212,7 @@ public void ParseDirectives()
private static void AssertThereAreNoErrors(ScriptResult result)
{
Assert.IsNotNull(result);
- Assert.IsTrue(result.Errors.Count == 0, string.Join(Environment.NewLine, result.Errors.Select(e => $"{e.Line} {e.Column} {e.Message}")));
+ Assert.IsTrue(result.Messages.Count == 0, string.Join(Environment.NewLine, result.Messages.Select(e => $"{e.Line} {e.Column} {e.Message}")));
}
private static bool HasScriptedTestContent(string line)
diff --git a/src/Scripty.Core/Logger.cs b/src/Scripty.Core/Logger.cs
new file mode 100644
index 0000000..5b016be
--- /dev/null
+++ b/src/Scripty.Core/Logger.cs
@@ -0,0 +1,40 @@
+using System.Collections.Generic;
+
+namespace Scripty.Core
+{
+ public class Logger
+ {
+ private List _messages;
+
+ public Logger(List messages)
+ {
+ _messages = messages;
+ }
+
+ public void Info(string message, int line = 0, int column = 0)
+ {
+ Message(MessageType.Info, message, line, column);
+ }
+
+ public void Warning(string message, int line = 0, int column = 0)
+ {
+ Message(MessageType.Warning, message, line, column);
+ }
+
+ public void Error(string message, int line = 0, int column = 0)
+ {
+ Message(MessageType.Error, message, line, column);
+ }
+
+ private void Message(MessageType type, string message, int line, int column)
+ {
+ _messages.Add(new ScriptMessage
+ {
+ MessageType = type,
+ Message = message,
+ Column = column,
+ Line = line
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Scripty.Core/ProjectTree/ProjectRoot.cs b/src/Scripty.Core/ProjectTree/ProjectRoot.cs
index 3fd0dfe..cd14d88 100644
--- a/src/Scripty.Core/ProjectTree/ProjectRoot.cs
+++ b/src/Scripty.Core/ProjectTree/ProjectRoot.cs
@@ -17,11 +17,13 @@ public class ProjectRoot : ProjectNode
private bool _generatedTree;
public ProjectRoot(string filePath)
- : this(filePath, null, null)
+ : this(filePath, null, null, null)
{
}
- public ProjectRoot(string projectFilePath, string solutionFilePath, IReadOnlyDictionary properties)
+ public ProjectRoot(string projectFilePath, string solutionFilePath,
+ IReadOnlyDictionary properties,
+ IReadOnlyDictionary customProperties)
: base(null, string.Empty, null, null)
{
FilePath = projectFilePath;
@@ -38,10 +40,22 @@ public ProjectRoot(string projectFilePath, string solutionFilePath, IReadOnlyDic
_properties[pair.Key] = pair.Value;
}
}
+
+ CustomProperties = new Dictionary();
+
+ if (customProperties != null)
+ {
+ foreach (var pair in customProperties)
+ {
+ CustomProperties[pair.Key] = pair.Value;
+ }
+ }
}
public string FilePath { get; }
+ public Dictionary CustomProperties { get; }
+
public MSBuildWorkspace Workspace
{
get
diff --git a/src/Scripty.Core/ScriptContext.cs b/src/Scripty.Core/ScriptContext.cs
index 9dd6c0a..2e0f03d 100644
--- a/src/Scripty.Core/ScriptContext.cs
+++ b/src/Scripty.Core/ScriptContext.cs
@@ -3,11 +3,14 @@
using Microsoft.CodeAnalysis.MSBuild;
using Scripty.Core.Output;
using Scripty.Core.ProjectTree;
+using System.Collections.Generic;
namespace Scripty.Core
{
public class ScriptContext : IDisposable
{
+ private List _messages = new List();
+
internal ScriptContext(string scriptFilePath, string projectFilePath, ProjectRoot projectRoot)
{
if (string.IsNullOrEmpty(scriptFilePath))
@@ -23,6 +26,7 @@ internal ScriptContext(string scriptFilePath, string projectFilePath, ProjectRoo
ProjectFilePath = projectFilePath;
Project = projectRoot;
Output = new OutputFileCollection(scriptFilePath);
+ Log = new Logger(_messages);
}
public void Dispose()
@@ -39,5 +43,12 @@ public void Dispose()
public ProjectRoot Project { get; }
public OutputFileCollection Output { get; }
+
+ public Logger Log { get; }
+
+ internal ICollection GetMessages()
+ {
+ return _messages;
+ }
}
}
\ No newline at end of file
diff --git a/src/Scripty.Core/ScriptEngine.cs b/src/Scripty.Core/ScriptEngine.cs
index 71e00e3..847b76d 100644
--- a/src/Scripty.Core/ScriptEngine.cs
+++ b/src/Scripty.Core/ScriptEngine.cs
@@ -21,11 +21,13 @@ public class ScriptEngine
private readonly string _projectFilePath;
public ScriptEngine(string projectFilePath)
- : this(projectFilePath, null, null)
+ : this(projectFilePath, null, null, null)
{
}
- public ScriptEngine(string projectFilePath, string solutionFilePath, IReadOnlyDictionary properties)
+ public ScriptEngine(string projectFilePath, string solutionFilePath,
+ IReadOnlyDictionary properties,
+ IReadOnlyDictionary customProperties = null)
{
if (string.IsNullOrEmpty(projectFilePath))
{
@@ -47,7 +49,7 @@ public ScriptEngine(string projectFilePath, string solutionFilePath, IReadOnlyDi
}
_projectFilePath = projectFilePath;
- ProjectRoot = new ProjectRoot(projectFilePath, solutionFilePath, properties);
+ ProjectRoot = new ProjectRoot(projectFilePath, solutionFilePath, properties, customProperties);
}
public ProjectRoot ProjectRoot { get; }
@@ -105,8 +107,9 @@ public async Task Evaluate(ScriptSource source)
{
return new ScriptResult(context.Output.OutputFiles,
compilationError.Diagnostics
- .Select(x => new ScriptError
+ .Select(x => new ScriptMessage
{
+ MessageType = MessageType.Error,
Message = x.GetMessage(),
Line = x.Location.GetLineSpan().StartLinePosition.Line,
Column = x.Location.GetLineSpan().StartLinePosition.Character
@@ -117,8 +120,9 @@ public async Task Evaluate(ScriptSource source)
{
return new ScriptResult(context.Output.OutputFiles,
aggregateException.InnerExceptions
- .Select(x => new ScriptError
+ .Select(x => new ScriptMessage
{
+ MessageType = MessageType.Error,
Message = x.ToString()
}).ToList());
}
@@ -127,13 +131,14 @@ public async Task Evaluate(ScriptSource source)
return new ScriptResult(context.Output.OutputFiles,
new[]
{
- new ScriptError
+ new ScriptMessage
{
+ MessageType = MessageType.Error,
Message = ex.ToString()
}
});
}
- return new ScriptResult(context.Output.OutputFiles);
+ return new ScriptResult(context.Output.OutputFiles, context.GetMessages());
}
}
diff --git a/src/Scripty.Core/ScriptError.cs b/src/Scripty.Core/ScriptError.cs
deleted file mode 100644
index a23cc53..0000000
--- a/src/Scripty.Core/ScriptError.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Scripty.Core
-{
- public class ScriptError
- {
- public string Message { get; set; }
- public int Line { get; set; }
- public int Column { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/Scripty.Core/ScriptMessage.cs b/src/Scripty.Core/ScriptMessage.cs
new file mode 100644
index 0000000..fd56b34
--- /dev/null
+++ b/src/Scripty.Core/ScriptMessage.cs
@@ -0,0 +1,17 @@
+namespace Scripty.Core
+{
+ public enum MessageType
+ {
+ Info,
+ Warning,
+ Error
+ }
+
+ public class ScriptMessage
+ {
+ public MessageType MessageType { get; set; }
+ public string Message { get; set; }
+ public int Line { get; set; }
+ public int Column { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Scripty.Core/ScriptResult.cs b/src/Scripty.Core/ScriptResult.cs
index ccf3bba..c48b18f 100644
--- a/src/Scripty.Core/ScriptResult.cs
+++ b/src/Scripty.Core/ScriptResult.cs
@@ -7,17 +7,17 @@ namespace Scripty.Core
public class ScriptResult
{
public ICollection OutputFiles { get; }
- public ICollection Errors { get; }
+ public ICollection Messages { get; }
internal ScriptResult(ICollection outputFiles)
- : this(outputFiles, Array.Empty())
+ : this(outputFiles, Array.Empty())
{
}
- internal ScriptResult(ICollection outputFiles, ICollection errors)
+ internal ScriptResult(ICollection outputFiles, ICollection errors)
{
OutputFiles = outputFiles;
- Errors = errors;
+ Messages = errors;
}
}
}
\ No newline at end of file
diff --git a/src/Scripty.Core/Scripty.Core.csproj b/src/Scripty.Core/Scripty.Core.csproj
index 12eda85..350ddd2 100644
--- a/src/Scripty.Core/Scripty.Core.csproj
+++ b/src/Scripty.Core/Scripty.Core.csproj
@@ -167,6 +167,7 @@
Properties\SolutionInfo.cs
+
@@ -186,7 +187,7 @@
-
+
diff --git a/src/Scripty.CustomTool/ScriptyGenerator.cs b/src/Scripty.CustomTool/ScriptyGenerator.cs
index 32a60d6..83468ab 100644
--- a/src/Scripty.CustomTool/ScriptyGenerator.cs
+++ b/src/Scripty.CustomTool/ScriptyGenerator.cs
@@ -59,11 +59,18 @@ protected override byte[] GenerateCode(string inputFileContent)
ScriptResult result = engine.Evaluate(source).Result;
// Report errors
- if (result.Errors.Count > 0)
+ if (result.Messages.Count > 0)
{
- foreach (ScriptError error in result.Errors)
+ foreach (ScriptMessage error in result.Messages)
{
- GeneratorError(4, error.Message, (uint) error.Line, (uint) error.Column);
+ switch (error.MessageType) {
+ case MessageType.Error:
+ GeneratorError(4, error.Message, (uint)error.Line, (uint)error.Column);
+ break;
+ case MessageType.Warning:
+ GeneratorWarning(4, error.Message, (uint)error.Line, (uint)error.Column);
+ break;
+ }
}
return null;
}
diff --git a/src/Scripty.MsBuild/MessageType.cs b/src/Scripty.MsBuild/MessageType.cs
new file mode 100644
index 0000000..9b1b737
--- /dev/null
+++ b/src/Scripty.MsBuild/MessageType.cs
@@ -0,0 +1,9 @@
+namespace Scripty.MsBuild
+{
+ internal enum MessageType
+ {
+ Info,
+ Warning,
+ Error
+ }
+}
\ No newline at end of file
diff --git a/src/Scripty.MsBuild/Scripty.MsBuild.csproj b/src/Scripty.MsBuild/Scripty.MsBuild.csproj
index 6889173..ff65b1c 100644
--- a/src/Scripty.MsBuild/Scripty.MsBuild.csproj
+++ b/src/Scripty.MsBuild/Scripty.MsBuild.csproj
@@ -51,9 +51,11 @@
Properties\SolutionInfo.cs
+
+
diff --git a/src/Scripty.MsBuild/ScriptyTask.cs b/src/Scripty.MsBuild/ScriptyTask.cs
index 2d47589..c44bfc5 100644
--- a/src/Scripty.MsBuild/ScriptyTask.cs
+++ b/src/Scripty.MsBuild/ScriptyTask.cs
@@ -28,6 +28,8 @@ public class ScriptyTask : Microsoft.Build.Utilities.Task
public string ScriptyExecutable { get; set; }
+ public string CustomProperties { get; set; }
+
public ITaskItem[] ScriptFiles { get; set; }
[Output]
@@ -98,6 +100,30 @@ public override bool Execute()
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();
+
+ var messages = errorData.Where(x => !string.IsNullOrWhiteSpace(x))
+ .Select(x => x.Split(new[] { '|' }, 2))
+ .Where(x => x.Length == 2)
+ .Select(x => new { MessageType = (MessageType)Enum.Parse(typeof(MessageType), x[0]), Message = x[1] })
+ .ToArray();
+
+ // Report any errors
+ foreach (var message in messages)
+ {
+ switch (message.MessageType)
+ {
+ case MessageType.Info:
+ Log.LogMessage(MessageImportance.High, message.Message);
+ break;
+ case MessageType.Warning:
+ Log.LogWarning(message.Message);
+ break;
+ case MessageType.Error:
+ Log.LogError(message.Message);
+ break;
+ }
+ }
+
if (process.ExitCode == 0)
{
Log.LogMessage("Finished script evaluation");
@@ -107,10 +133,8 @@ public override bool Execute()
Log.LogError("Got non-zero exit code from script evaluation: " + process.ExitCode);
}
- // Report any errors
- foreach (string error in errorData.Where(x => !string.IsNullOrWhiteSpace(x)))
+ if (messages.Where(m => m.MessageType == MessageType.Error).Any())
{
- Log.LogError(error);
return false;
}
@@ -176,6 +200,7 @@ private string GetSettingsJson()
{
Settings settings = new Settings
{
+ MessagesEnabled = true,
ProjectFilePath = ProjectFilePath,
Properties = GetMsBuildProperties(),
ScriptFilePaths = ScriptFiles
@@ -183,11 +208,35 @@ private string GetSettingsJson()
.Where(x => !string.IsNullOrEmpty(x))
.Distinct()
.ToList(),
- SolutionFilePath = SolutionFilePath?.Contains("*Undefined*") == true ? null : SolutionFilePath
+ SolutionFilePath = SolutionFilePath?.Contains("*Undefined*") == true ? null : SolutionFilePath,
+ CustomProperties = GetCustomProperties()
};
return JsonConvert.SerializeObject(settings);
}
+ private IDictionary GetCustomProperties()
+ {
+ if (CustomProperties == null)
+ return null;
+
+ var result = new Dictionary();
+ var parts = Utils.AsList(CustomProperties, new char[] { ';', '=' });
+
+ if (parts.Count % 2 != 0)
+ {
+ throw new Exception("Invalid CustomProperties");
+ }
+
+ for (int i = 0; i < parts.Count; i += 2)
+ {
+ var key = parts[i];
+ var value = parts[i + 1];
+
+ result[key] = value;
+ }
+ return result;
+ }
+
private IDictionary GetMsBuildProperties()
{
// We need to use reflection to get
diff --git a/src/Scripty.MsBuild/Settings.cs b/src/Scripty.MsBuild/Settings.cs
index ee4635f..9e2e1ed 100644
--- a/src/Scripty.MsBuild/Settings.cs
+++ b/src/Scripty.MsBuild/Settings.cs
@@ -11,9 +11,11 @@ namespace Scripty.MsBuild
///
public class Settings
{
+ public bool MessagesEnabled = false;
public string ProjectFilePath = null;
public string SolutionFilePath = null;
public IList ScriptFilePaths = null;
public IDictionary Properties = null;
+ public IDictionary CustomProperties = null;
}
}
diff --git a/src/Scripty.MsBuild/Utils.cs b/src/Scripty.MsBuild/Utils.cs
new file mode 100644
index 0000000..59bfd8d
--- /dev/null
+++ b/src/Scripty.MsBuild/Utils.cs
@@ -0,0 +1,126 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Scripty.MsBuild
+{
+ class Utils
+ {
+ private const char QUOTE_CHAR = '"';
+
+ static void SkipBlanks(ref int index, string csvString)
+ {
+ while (index < csvString.Length &&
+ csvString[index] == ' ')
+ index++;
+ }
+
+ public static List AsList(string csvString, IEnumerable separators = null, char escapeChar = '\\', bool skipBlanks = true)
+ {
+ HashSet seps;
+ if (separators == null)
+ {
+ seps = new HashSet();
+ seps.Add(';');
+ }
+ else
+ seps = new HashSet(separators);
+
+ bool quoteCharIsSame = escapeChar == QUOTE_CHAR;
+
+ var list = new List();
+ bool markOn = false;
+ csvString = skipBlanks ? csvString.Trim() : csvString;
+ if (csvString.Length == 0)
+ return list;
+ int index = 0;
+ StringBuilder s = new StringBuilder();
+ bool ending = false;
+
+ if (skipBlanks) SkipBlanks(ref index, csvString);
+
+ bool inEscape = false;
+
+ while (index < csvString.Length && !ending)
+ {
+ if (!inEscape && csvString[index] == QUOTE_CHAR)
+ {
+ // start quoted item
+ if (!markOn && s.Length == 0)
+ markOn = true;
+ else
+ // last quote
+ if (index == csvString.Length - 1)
+ {
+ list.Add(s.ToString());
+ s.Length = 0;
+ markOn = false;
+ ending = true;
+ }
+ else
+ { // part of item ?
+ if (markOn)
+ {
+ // next quote mark for literal char
+ if (quoteCharIsSame && csvString[index + 1] == '"')
+ {
+ s.Append('"');
+ index++;
+ }
+ else
+ // end quoted item
+ markOn = false;
+ }
+ // not marked, is literal char
+ else
+ s.Append(QUOTE_CHAR);
+ }
+ }
+ else if (!markOn && csvString[index] == '\r')
+ {
+ // ignore cr
+ }
+ else if (!markOn && csvString[index] == '\n')
+ {
+ ending = true; break; // end of line
+ }
+ else
+ {
+ // check separator
+ if (seps.Contains(csvString[index]))
+ {
+ // delimiter is part of string
+ if (markOn)
+ s.Append(csvString[index]);
+ else
+ {
+ list.Add(s.ToString());
+ s.Length = 0;
+ markOn = false;
+ index++; // after ;
+ if (skipBlanks) SkipBlanks(ref index, csvString);
+ continue; // don't jump to increment index
+ }
+ }
+ else if (markOn && !inEscape && csvString[index] == escapeChar)
+ {
+ inEscape = true;
+ }
+ else
+ {
+ inEscape = false;
+ s.Append(csvString[index]);
+ }
+ }
+ index++;
+ }
+
+ // if line ends without Delimiter
+ if (s.Length > 0)
+ list.Add(s.ToString());
+ return list;
+ }
+ }
+}
diff --git a/src/Scripty/Program.cs b/src/Scripty/Program.cs
index 55bd90a..2321060 100644
--- a/src/Scripty/Program.cs
+++ b/src/Scripty/Program.cs
@@ -17,18 +17,30 @@ public class Program
{
private static int Main(string[] args)
{
- AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionEvent;
Program program = new Program();
+ AppDomain.CurrentDomain.UnhandledException += program.UnhandledExceptionEvent;
return program.Run(args);
}
- private static void UnhandledExceptionEvent(object sender, UnhandledExceptionEventArgs e)
+ private void WriteMessage(MessageType type, string message)
+ {
+ if (_settings.MessagesEnabled)
+ {
+ Console.Error.WriteLine(string.Format("{0}|{1}", type, message));
+ }
+ else if (type == MessageType.Error)
+ {
+ Console.Error.WriteLine(message);
+ }
+ }
+
+ private void UnhandledExceptionEvent(object sender, UnhandledExceptionEventArgs e)
{
// Exit with a error exit code
Exception exception = e.ExceptionObject as Exception;
if (exception != null)
{
- Console.Error.WriteLine(exception.ToString());
+ WriteMessage(MessageType.Error, exception.ToString());
}
Environment.Exit((int) ExitCode.UnhandledError);
}
@@ -50,7 +62,7 @@ private int Run(string[] args)
}
catch (Exception ex)
{
- Console.Error.WriteLine(ex.ToString());
+ WriteMessage(MessageType.Error, ex.ToString());
return (int) ExitCode.CommandLineError;
}
}
@@ -88,7 +100,8 @@ private int Run(string[] args)
solutionFilePath = Path.Combine(Environment.CurrentDirectory, _settings.SolutionFilePath);
}
- ScriptEngine engine = new ScriptEngine(projectFilePath, solutionFilePath, _settings.Properties);
+ ScriptEngine engine = new ScriptEngine(projectFilePath, solutionFilePath,
+ _settings.Properties, _settings.CustomProperties);
// Get script files if none were specified
IReadOnlyList finalScriptFilePaths;
@@ -129,17 +142,24 @@ private int Run(string[] args)
{
foreach (Exception ex in aggregateException.InnerExceptions)
{
- Console.Error.WriteLine(ex.ToString());
+ WriteMessage(MessageType.Error, ex.ToString());
}
}
// Iterate over the completed tasks
foreach (Task task in tasks.Where(x => x.Status == TaskStatus.RanToCompletion))
{
- // Check for any errors
- foreach (ScriptError error in task.Result.Errors)
+ // Check for any mesages.
+ foreach (ScriptMessage message in task.Result.Messages)
{
- Console.Error.WriteLine($"{error.Message} [{error.Line},{error.Column}]");
+ if (message.Line == 0 || message.Column == 0)
+ {
+ WriteMessage(message.MessageType, message.Message);
+ }
+ else
+ {
+ WriteMessage(message.MessageType, $"{message.Message} [{message.Line},{message.Column}]");
+ }
}
// Output the set of generated files w/ build actions
diff --git a/src/Scripty/Settings.cs b/src/Scripty/Settings.cs
index ce02989..90f1c6a 100644
--- a/src/Scripty/Settings.cs
+++ b/src/Scripty/Settings.cs
@@ -14,13 +14,16 @@ public class Settings
public IReadOnlyList ScriptFilePaths = null;
public IReadOnlyDictionary Properties = null;
public bool Attach = false;
-
+ public bool MessagesEnabled = false;
+ public IReadOnlyDictionary CustomProperties = null;
+
private IReadOnlyList> _properties = null;
public bool ParseArgs(string[] args, out bool hasErrors)
{
System.CommandLine.ArgumentSyntax parsed = System.CommandLine.ArgumentSyntax.Parse(args, syntax =>
{
+ syntax.DefineOption("enableMessages", ref MessagesEnabled, "Enables passing of information and warnings to MsBuild.");
syntax.DefineOption("attach", ref Attach, "Pause execution at the start of the program until a debugger is attached.");
syntax.DefineOption("solution", ref SolutionFilePath, "The full path of the solution file that contains the project.");
syntax.DefineOptionList("p", ref _properties, ParseProperty, "The build properties.");