--- /dev/null
+//
+// AssemblyInfo.cs
+//
+// Author:
+// Marek Sieradzki (mare.sieradzki@gmail.com
+//
+// (C) 2005 Marek Sieradzki
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the Microsoft.Build.Utilities assembly
+
+[assembly: AssemblyVersion (Consts.FxVersion)]
+[assembly: SatelliteContractVersion (Consts.FxVersion)]
+
+[assembly: AssemblyTitle("Microsoft.Build.Utilities.dll")]
+[assembly: AssemblyDescription("Microsoft.Build.Utilities.dll")]
+[assembly: AssemblyConfiguration("Development version")]
+[assembly: AssemblyCompany("Marek Sieradzki")]
+[assembly: AssemblyProduct("MONO CLI")]
+[assembly: AssemblyCopyright("(c) 2005 Marek Sieradzki")]
+[assembly: AssemblyTrademark("")]
+
+[assembly: CLSCompliant(true)]
+[assembly: AssemblyDefaultAlias("Microsoft.Build.Utilities.dll")]
+[assembly: AssemblyInformationalVersion("0.0.0.1")]
+[assembly: NeutralResourcesLanguage("en-US")]
+
+[assembly: ComVisible(false)]
+[assembly: AllowPartiallyTrustedCallers]
+
+[assembly: AssemblyDelaySign(true)]
+[assembly: AssemblyKeyFile("../msfinal.pub")]
--- /dev/null
+2005-09-09 Marek Sieradzki <marek.sieradzki@gmail.com>
+
+ * Microsoft.Build.Utilities.dll.sources: Renamed from
+ Microsoft.Build.Utilities.sources.
+ * Microsoft.Build.Utilities_test.dll.sources: Added.
+ * Makefile: Added Microsoft.Build.Framework.dll to test references.
--- /dev/null
+thisdir = class/Microsoft.Build.Utilities
+SUBDIRS =
+include ../../build/rules.make
+
+LIBRARY = Microsoft.Build.Utilities.dll
+LIB_MCS_FLAGS = \
+ /r:$(corlib) \
+ /r:System.dll \
+ /r:Microsoft.Build.Framework.dll
+
+TEST_MCS_FLAGS = /r:Microsoft.Build.Framework.dll
+
+include ../../build/library.make
--- /dev/null
+../../build/common/Consts.cs
+Assembly/AssemblyInfo.cs
+Microsoft.Build.Utilities/AppDomainIsolatedTask.cs
+Microsoft.Build.Utilities/CommandLineBuilder.cs
+Microsoft.Build.Utilities/ConcurrentLoggingHelper.cs
+Microsoft.Build.Utilities/Logger.cs
+Microsoft.Build.Utilities/MonoTODOAttribute.cs
+Microsoft.Build.Utilities/TargetDotNetFrameworkVersion.cs
+Microsoft.Build.Utilities/Task.cs
+Microsoft.Build.Utilities/TaskItem.cs
+Microsoft.Build.Utilities/TaskLoggingHelper.cs
+Microsoft.Build.Utilities/ToolLocationHelper.cs
+Microsoft.Build.Utilities/ToolTask.cs
--- /dev/null
+<Project name="Microsoft.Build.Utilities" fileversion="2.0" language="C#" ctype="DotNetProject">
+ <Configurations active="Debug">
+ <Configuration name="Debug" ctype="DotNetProjectConfiguration">
+ <Output directory="./bin/Debug" assembly="Microsoft.Build.Utilities" />
+ <Build debugmode="True" target="Library" />
+ <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" />
+ <CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+ </Configuration>
+ <Configuration name="Release" ctype="DotNetProjectConfiguration">
+ <Output directory="./bin/Release" assembly="Microsoft.Build.Utilities" />
+ <Build debugmode="False" target="Library" />
+ <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" />
+ <CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+ </Configuration>
+ </Configurations>
+ <DeploymentInformation strategy="File">
+ <excludeFiles />
+ </DeploymentInformation>
+ <Contents>
+ <File name="./Microsoft.Build.Utilities/AppDomainIsolatedTask.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Microsoft.Build.Utilities/CommandLineBuilder.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Microsoft.Build.Utilities/ConcurrentLoggingHelper.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Microsoft.Build.Utilities/Logger.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Microsoft.Build.Utilities/MonoTODOAttribute.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Microsoft.Build.Utilities/TargetDotNetFrameworkVersion.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Microsoft.Build.Utilities/Task.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Microsoft.Build.Utilities/TaskItem.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Microsoft.Build.Utilities/TaskLoggingHelper.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Microsoft.Build.Utilities/ToolLocationHelper.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Microsoft.Build.Utilities/ToolTask.cs" subtype="Code" buildaction="Compile" />
+ </Contents>
+ <References>
+ <ProjectReference type="Project" localcopy="True" refto="Microsoft.Build.Framework" />
+ <ProjectReference type="Gac" localcopy="True" refto="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ </References>
+</Project>
\ No newline at end of file
--- /dev/null
+<Combine name="Microsoft.Build.Utilities" fileversion="2.0">
+ <Configurations active="Debug">
+ <Configuration name="Debug" ctype="CombineConfiguration">
+ <Entry configuration="Debug" build="True" name="Microsoft.Build.Utilities" />
+ </Configuration>
+ <Configuration name="Release" ctype="CombineConfiguration">
+ <Entry configuration="Debug" build="True" name="Microsoft.Build.Utilities" />
+ </Configuration>
+ </Configurations>
+ <StartMode startupentry="Microsoft.Build.Utilities" single="True">
+ <Execute type="None" entry="Microsoft.Build.Utilities" />
+ </StartMode>
+ <Entries>
+ <Entry filename="./Microsoft.Build.Utilities.mdp" />
+ </Entries>
+</Combine>
\ No newline at end of file
--- /dev/null
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <MicrosoftBuildUtilitiesSources Include="Microsoft.Build.Utilities/Microsoft.Build.Utilities/*.cs" />
+ <MicrosoftBuildUtilitiesDll Include="Microsoft.Build.Utilities.dll" />
+ <MicrosoftBuildUtilitiesReferences Include="Microsoft.Build.Framework.dll" />
+ </ItemGroup>
+ <Target
+ Name="MicrosoftBuildUtilities"
+ DependsOnTargets="MicrosoftBuildFramework"
+ Inputs="@(MicrosoftBuildUtilitiesSources)"
+ Outputs="@(MicrosoftBuildUtilitiesDll)"
+ >
+ <Csc
+ Sources="@(MicrosoftBuildUtilitiesSources)"
+ TargetType="library"
+ OutputAssembly="@(MicrosoftBuildUtilitiesDll)"
+ References="@(MicrosoftBuildUtilitiesReferences)"
+ WarningLevel="3"
+ />
+ </Target>
+</Project>
--- /dev/null
+//
+// AppDomainIsolatedTask.cs: Task that should be run separate appdomain.
+//
+// Author:
+// Marek Sieradzki (marek.sieradzki@gmail.com)
+//
+// (C) 2005 Marek Sieradzki
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+using System;
+using System.Resources;
+using Microsoft.Build.Framework;
+
+namespace Microsoft.Build.Utilities
+{
+ [LoadInSeparateAppDomainAttribute]
+ public abstract class AppDomainIsolatedTask : MarshalByRefObject, ITask
+ {
+ IBuildEngine buildEngine;
+ string helpKeywordPrefix;
+ object hostObject;
+ TaskLoggingHelper log;
+ ResourceManager taskResources;
+
+ protected AppDomainIsolatedTask ()
+ : this (null, null)
+ {
+ }
+
+ protected AppDomainIsolatedTask (ResourceManager taskResources)
+ : this (taskResources, null)
+ {
+ }
+
+ protected AppDomainIsolatedTask (ResourceManager taskResources,
+ string helpKeywordPrefix)
+ {
+ this.taskResources = taskResources;
+ this.helpKeywordPrefix = helpKeywordPrefix;
+ }
+
+ public abstract bool Execute ();
+
+ public override object InitializeLifetimeService ()
+ {
+ return null;
+ }
+
+ public IBuildEngine BuildEngine {
+ get {
+ return buildEngine;
+ }
+ set {
+ buildEngine = value;
+ }
+ }
+
+ protected string HelpKeywordPrefix {
+ get {
+ return helpKeywordPrefix;
+ }
+ set {
+ helpKeywordPrefix = value;
+ }
+ }
+
+ public object HostObject {
+ get {
+ return hostObject;
+ }
+ set {
+ hostObject = value;
+ }
+ }
+
+ public TaskLoggingHelper Log {
+ get {
+ return log;
+ }
+ }
+
+ protected ResourceManager TaskResources {
+ get {
+ return taskResources;
+ }
+ set {
+ taskResources = value;
+ }
+ }
+ }
+}
--- /dev/null
+2005-09-09 Marek Sieradzki <marek.sieradzki@gmail.com>
+
+ * CommandLineBuilder.cs, Logger.cs, AppDomainIsolatedTask.cs,
+ ConcurrentLoggingHelper.cs, TaskLoggingHelper.cs: Changed protected
+ fields to private.
+
+2005-08-30 Marek Sieradzki <marek.sieradzki@gmail.com>
+
+ * TaskItem.cs, TaskLoggingHelper.cs: Formatting.
+
+2005-08-27 Marek Sieradzki <marek.sieradzki@gmail.com>
+
+ * Logger.cs: Formatting.
+ * ToolTask.cs: Added error/warning handling.
+ * TaskLoggingHelper.cs: Fixed LogErrorFromException ().
+
+2005-08-24 Marek Sieradzki <marek.sieradzki@gmail.com>
+
+ * CommandLineBuilder.cs: Added checking for null values.
+ * ToolTask.cs: Added real execution.
+ * Task.cs: Changed all fields to private.
+ * TaskLoggingHelper.cs: Formatting.
+
+2005-08-19 Marek Sieradzki <marek.sieradzki@gmail.com>
+
+ * TaskItem.cs: MetadataCount fixed.
+
+2005-08-16 Marek Sieradzki <marek.sieradzki@gmail.com>
+
+ * Task.cs: Added creation of TaskLoggingHelper.cs.
+ * TaskLoggingHelper.cs: Ctor uses Task's BuildEngine.
+
+2005-08-14 Marek Sieradzki <marek.sieradzki@gmail.com>
+
+ * TaskItem.cs: Added GetMetadata and fixed other functions.
+
+2005-08-12 Marek Sieradzki <marek.sieradzki@gmail.com>
+
+ * CommandLineBuilder.cs: Add appending spaces (currently commented)
+ * ToolTask.cs: Add process.
+
+2005-08-06 Marek Sieradzki <marek.sieradzki@gmail.com>
+
+ * AppDomainIsolatedTask.cs, CommandLineBuilder.cs,
+ ConcurrentLoggingHelper.cs, Logger.cs, Task.cs, TaskItem.cs,
+ TaskLoggingHelper.cs, ToolTask.cs: Various fixes.
+
+2005-07-13 Marek Sieradzki <marek.sieradzki@gmail.com>
+
+ * Logger.cs, AppDomainIsolatedTask.cs, ToolTask.cs, TaskItem.cs,
+ ConcurrentLoggingHelper.cs, TaskLoggingHelper.cs: Small fixes, still
+ unusable
+
+2005-07-05 Marek Sieradzki <marek.sieradzki@gmail.com>
+
+ * AppDomainIsolatedTask.cs, CommandLineBuilder.cs,
+ ConcurrentLoggingHelper.cs, Logger.cs, MonoTODOAttribute.cs,
+ TargetDotNetFrameworkVersion.cs, Task.cs, TaskItem.cs,
+ TaskLoggingHelper.cs, ToolLocationHelper.cs, ToolTask.cs: Initial
+ check-in, very buggy
--- /dev/null
+//
+// CommandLineBuilder.cs: Builds command line options string
+//
+// Author:
+// Marek Sieradzki (marek.sieradzki@gmail.com)
+//
+// (C) 2005 Marek Sieradzki
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+using System;
+using System.Text;
+using Microsoft.Build.Framework;
+
+namespace Microsoft.Build.Utilities
+{
+ public class CommandLineBuilder
+ {
+ StringBuilder commandLine;
+
+ public CommandLineBuilder ()
+ {
+ commandLine = new StringBuilder ();
+ }
+
+ public void AppendFileNameIfNotNull (string fileName)
+ {
+ if (fileName == null)
+ return;
+ AppendSpaceIfNotEmpty ();
+ commandLine.Append (fileName);
+ }
+
+ public void AppendFileNameIfNotNull (ITaskItem fileItem)
+ {
+ if (fileItem == null)
+ return;
+ AppendSpaceIfNotEmpty ();
+ commandLine.Append (fileItem.ToString());
+ }
+
+ public void AppendFileNamesIfNotNull (string[] fileNames,
+ string delimiter)
+ {
+ if (fileNames == null)
+ return;
+ bool appendDelimiter = false;
+ AppendSpaceIfNotEmpty ();
+ for (int i = 0; i < fileNames.Length; i++) {
+ if (fileNames [i] == null)
+ continue;
+ if (appendDelimiter) {
+ commandLine.Append (delimiter);
+ commandLine.Append (fileNames [i]);
+ } else {
+ commandLine.Append (fileNames [i]);
+ appendDelimiter = true;
+ }
+ }
+ }
+
+ public void AppendFileNamesIfNotNull (ITaskItem[] fileItems,
+ string delimiter)
+ {
+ if (fileItems == null)
+ return;
+ bool appendDelimiter = false;
+ AppendSpaceIfNotEmpty ();
+ for (int i = 0; i < fileItems.Length; i++) {
+ if (fileItems [i] == null)
+ continue;
+ if (appendDelimiter) {
+ commandLine.Append (delimiter);
+ commandLine.Append (fileItems [i].ToString ());
+ } else {
+ commandLine.Append (fileItems [i].ToString ());
+ appendDelimiter = true;
+ }
+ }
+ }
+
+ protected void AppendFileNamesWithQuoting (string fileName)
+ {
+ if (IsQuotingRequired (fileName))
+ commandLine.AppendFormat ("\"{0}\"",fileName);
+ else
+ commandLine.Append (fileName);
+ }
+
+ protected void AppendSpaceIfNotEmpty ()
+ {
+ if (commandLine.Length != 0)
+ commandLine.Append (' ');
+ }
+
+ public void AppendSwitch (string switchName)
+ {
+ if (switchName == null)
+ return;
+ AppendSpaceIfNotEmpty ();
+ commandLine.Append (switchName);
+ }
+
+ public void AppendSwitchIfNotNull (string switchName,
+ string parameter)
+ {
+ if (switchName == null || parameter == null)
+ return;
+ AppendSpaceIfNotEmpty ();
+ commandLine.AppendFormat ("{0}{1}",switchName,
+ parameter);
+ }
+
+ public void AppendSwitchIfNotNull (string switchName,
+ ITaskItem parameter)
+ {
+ if (switchName == null || parameter == null)
+ return;
+ AppendSpaceIfNotEmpty ();
+ commandLine.AppendFormat ("{0}{1}",switchName,
+ parameter.ToString ());
+ }
+
+ public void AppendSwitchIfNotNull (string switchName,
+ string[] parameters,
+ string delimiter)
+ {
+ if (switchName == null || parameters == null)
+ return;
+ AppendSpaceIfNotEmpty ();
+ commandLine.AppendFormat ("{0}",switchName);
+ bool appendDelimiter = false;
+ for (int i = 0; i < parameters.Length; i++) {
+ if (parameters [i] == null)
+ continue;
+ if (appendDelimiter) {
+ commandLine.Append (delimiter);
+ commandLine.Append (parameters [i]);
+ } else {
+ commandLine.Append (parameters [i]);
+ appendDelimiter = true;
+ }
+ }
+ }
+
+ public void AppendSwitchIfNotNull (string switchName,
+ ITaskItem[] parameters,
+ string delimiter)
+ {
+ if (switchName == null || parameters == null)
+ return;
+ AppendSpaceIfNotEmpty ();
+ commandLine.AppendFormat ("{0}",switchName);
+ bool appendDelimiter = false;
+ for (int i = 0; i < parameters.Length; i++) {
+ if (parameters [i] == null)
+ continue;
+ if (appendDelimiter) {
+ commandLine.Append (delimiter);
+ commandLine.Append (parameters [i].ToString ());
+ } else {
+ commandLine.Append (parameters [i].ToString ());
+ appendDelimiter = true;
+ }
+ }
+ }
+
+ public void AppendSwitchUnquotedIfNotNull (string switchName,
+ string parameter)
+ {
+ if (switchName == null || parameter == null)
+ return;
+ AppendSpaceIfNotEmpty ();
+ commandLine.AppendFormat ("{0}{1}", switchName, parameter);
+ }
+
+ public void AppendSwitchUnquotedIfNotNull (string switchName,
+ ITaskItem parameter)
+ {
+ if (switchName == null || parameter == null)
+ return;
+ AppendSpaceIfNotEmpty ();
+ commandLine.AppendFormat ("{0}{1}", switchName, parameter.GetMetadata ("Include"));
+ }
+
+ public void AppendSwitchUnquotedIfNotNull (string switchName,
+ string[] parameters,
+ string delimiter)
+ {
+ if (switchName == null || delimiter == null || parameters == null)
+ return;
+ AppendSpaceIfNotEmpty ();
+ commandLine.AppendFormat ("{0}",switchName);
+ bool appendDelimiter = false;
+ for (int i = 0; i < parameters.Length; i++) {
+ if (parameters [i] == null)
+ continue;
+ if (appendDelimiter) {
+ commandLine.Append (delimiter);
+ commandLine.Append (parameters [i]);
+ } else {
+ commandLine.Append (parameters [i]);
+ appendDelimiter = true;
+ }
+ }
+ }
+
+ public void AppendSwitchUnquotedIfNotNull (string switchName,
+ ITaskItem[] parameters,
+ string delimiter)
+ {
+ if (switchName == null || delimiter == null || parameters == null)
+ return;
+ AppendSpaceIfNotEmpty ();
+ commandLine.AppendFormat ("{0}",switchName);
+ bool appendDelimiter = false;
+ for (int i = 0; i < parameters.Length; i++) {
+ if (parameters [i] == null)
+ continue;
+ if (appendDelimiter) {
+ commandLine.Append (delimiter);
+ commandLine.Append (parameters [i].ToString ());
+ } else {
+ commandLine.Append (parameters [i].ToString ());
+ appendDelimiter = true;
+ }
+ }
+ }
+
+ protected void AppendTextUnquoted (string textToAppend)
+ {
+ commandLine.Append (textToAppend);
+ }
+
+ protected void AppendTextWithQuoting (string textToAppend)
+ {
+ if (IsQuotingRequired (textToAppend))
+ commandLine.AppendFormat ("\"{0}\"",textToAppend);
+ else
+ commandLine.Append (textToAppend);
+ }
+
+ protected virtual bool IsQuotingRequired (string parameter)
+ {
+ parameter.Trim ();
+ // FIXME: change this to regex
+ foreach (char c in parameter) {
+ if (c == ' ' || c == '\t' || c == '\u000b' || c == '\u000c')
+ return true;
+ }
+ return false;
+ }
+
+ public override string ToString ()
+ {
+ return commandLine.ToString ();
+ }
+
+ protected StringBuilder CommandLine {
+ get {
+ return commandLine;
+ }
+ }
+ }
+}
--- /dev/null
+//
+// ConcurrentLoggingHelper.cs:
+//
+// Author:
+// Marek Sieradzki (marek.sieradzki@gmail.com)
+//
+// (C) 2005 Marek Sieradzki
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+using System;
+using System.IO;
+using Microsoft.Build.Framework;
+
+namespace Microsoft.Build.Utilities
+{
+ public class ConcurrentLoggingHelper
+ {
+ bool hasLoggedErrors;
+ MessageImportance messageImportance;
+ StreamReader messageStream;
+ TaskLoggingHelper taskLog;
+
+ public ConcurrentLoggingHelper ()
+ : this (null, null, MessageImportance.Normal)
+ {
+ }
+
+ public ConcurrentLoggingHelper (TaskLoggingHelper taskLog,
+ StreamReader messageStream,
+ MessageImportance messageImportance)
+ {
+ this.taskLog = taskLog;
+ this.messageStream = messageStream;
+ this.messageImportance = messageImportance;
+ this.hasLoggedErrors = false;
+ }
+
+ [MonoTODO]
+ public void AbortLogging ()
+ {
+ }
+
+ [MonoTODO]
+ public void StartLogging ()
+ {
+ }
+
+ [MonoTODO]
+ public void StopLogging ()
+ {
+ }
+
+ [MonoTODO]
+ public bool StopLogging (TimeSpan timeout)
+ {
+ return true;
+ }
+
+ public bool HasLoggedErrors {
+ get {
+ return hasLoggedErrors;
+ }
+ }
+
+ public MessageImportance MessageImportance {
+ get {
+ return messageImportance;
+ }
+ set {
+ messageImportance = value;
+ }
+ }
+
+ public StreamReader MessageStream {
+ get {
+ return messageStream;
+ }
+ set {
+ messageStream = value;
+ }
+ }
+
+ public TaskLoggingHelper TaskLog {
+ get {
+ return taskLog;
+ }
+ set {
+ taskLog = value;
+ }
+ }
+ }
+}
--- /dev/null
+//
+// Logger.cs: Logs warning and errors.
+//
+// Author:
+// Marek Sieradzki (marek.sieradzki@gmail.com)
+//
+// (C) 2005 Marek Sieradzki
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+using System;
+using Microsoft.Build.Framework;
+
+namespace Microsoft.Build.Utilities
+{
+ public abstract class Logger : ILogger
+ {
+ string parameters;
+ LoggerVerbosity verbosity;
+
+ protected Logger ()
+ {
+ }
+
+ public string Parameters {
+ get {
+ return parameters;
+ }
+ set {
+ parameters = value;
+ }
+ }
+
+ public LoggerVerbosity Verbosity {
+ get {
+ return verbosity;
+ }
+ set {
+ verbosity = value;
+ }
+ }
+
+ public virtual string FormatErrorEvent (BuildErrorEventArgs args)
+ {
+ return String.Format ("{0}({1},{2},{3},{4}): {5} error {6}: {7}",
+ args.File, args.LineNumber, args.ColumnNumber, args.EndLineNumber, args.EndColumnNumber,
+ args.Subcategory, args.Code, args.Message);
+ }
+
+ public virtual string FormatWarningEvent (BuildWarningEventArgs args)
+ {
+ return String.Format ("{0}({1},{2},{3},{4}): {5} warning {6}: {7}",
+ args.File, args.LineNumber, args.ColumnNumber, args.EndLineNumber, args.EndColumnNumber,
+ args.Subcategory, args.Code, args.Message);
+ }
+
+ public abstract void Initialize (IEventSource eventSource);
+
+ public virtual void Shutdown ()
+ {
+ }
+ }
+}
--- /dev/null
+//
+// MonoTODOAttribute.cs
+//
+// Author:
+// Ravi Pratap (ravi@ximian.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System {
+
+ [AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
+ internal sealed class MonoTODOAttribute : Attribute {
+
+ string comment;
+
+ public MonoTODOAttribute ()
+ {
+ }
+
+ public MonoTODOAttribute (string comment)
+ {
+ this.comment = comment;
+ }
+
+ public string Comment {
+ get { return comment; }
+ }
+ }
+}
--- /dev/null
+//
+// TargetDotNetFrameworkVersion.cs: Represents framework version.
+//
+// Author:
+// Marek Sieradzki (marek.sieradzki@gmail.com)
+//
+// (C) 2005 Marek Sieradzki
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+namespace Microsoft.Build.Utilities
+{
+ public enum TargetDotNetFrameworkVersion
+ {
+ Version11,
+ Version20,
+ VersionLatest = Version20
+ }
+}
--- /dev/null
+//
+// Task.cs: Represents a task.
+//
+// Author:
+// Marek Sieradzki (marek.sieradzki@gmail.com)
+//
+// (C) 2005 Marek Sieradzki
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+using System;
+using System.Resources;
+using Microsoft.Build.Framework;
+
+namespace Microsoft.Build.Utilities
+{
+ public abstract class Task : ITask
+ {
+ IBuildEngine buildEngine;
+ string helpKeywordPrefix;
+ object hostObject;
+ TaskLoggingHelper log;
+ ResourceManager taskResources;
+
+ protected Task()
+ : this (null, null)
+ {
+ }
+
+ protected Task(ResourceManager taskResources)
+ : this (taskResources, null)
+ {
+ }
+
+ protected Task(ResourceManager taskResources,
+ string helpKeywordPrefix)
+ {
+ this.taskResources = taskResources;
+ this.helpKeywordPrefix = helpKeywordPrefix;
+ }
+
+ public abstract bool Execute();
+
+ public IBuildEngine BuildEngine {
+ get {
+ return buildEngine;
+ }
+ set {
+ buildEngine = value;
+ log = new TaskLoggingHelper (this);
+ }
+ }
+
+ protected string HelpKeywordPrefix {
+ get {
+ return helpKeywordPrefix;
+ }
+ set {
+ helpKeywordPrefix = value;
+ }
+ }
+
+ public object HostObject {
+ get {
+ return hostObject;
+ }
+ set {
+ hostObject = value;
+ }
+ }
+
+ public TaskLoggingHelper Log {
+ get {
+ return log;
+ }
+ }
+
+ protected ResourceManager TaskResources {
+ get {
+ return taskResources;
+ }
+ set {
+ taskResources = value;
+ }
+ }
+ }
+}
--- /dev/null
+//
+// TaskItem.cs: Represents an item belonging to a task.
+//
+// Author:
+// Marek Sieradzki (marek.sieradzki@gmail.com)
+//
+// (C) 2005 Marek Sieradzki
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+using System;
+using System.Collections;
+using System.IO;
+using Microsoft.Build.Framework;
+
+namespace Microsoft.Build.Utilities
+{
+ public sealed class TaskItem : MarshalByRefObject, ITaskItem
+ {
+ IDictionary metadata;
+ string itemSpec;
+ string recursiveDir;
+
+ public TaskItem ()
+ {
+ this.itemSpec = String.Empty;
+ this.recursiveDir = String.Empty;
+ this.metadata = new Hashtable (new CaseInsensitiveHashCodeProvider (), new CaseInsensitiveComparer ());
+ }
+
+ public TaskItem (ITaskItem sourceItem)
+ {
+ this.itemSpec = sourceItem.ItemSpec;
+ this.recursiveDir = String.Empty;
+ this.metadata = sourceItem.CloneCustomMetadata ();
+ }
+
+ public TaskItem (string itemSpec)
+ {
+ this.ItemSpec = itemSpec;
+ this.recursiveDir = String.Empty;
+ metadata = new Hashtable (new CaseInsensitiveHashCodeProvider (), new CaseInsensitiveComparer ());
+ }
+
+ public TaskItem (string itemSpec, IDictionary itemMetadata)
+ {
+ this.itemSpec = itemSpec;
+ this.recursiveDir = String.Empty;
+ this.metadata = itemMetadata;
+ }
+
+ public IDictionary CloneCustomMetadata ()
+ {
+ IDictionary clonedMetadata = new Hashtable (new CaseInsensitiveHashCodeProvider (), new CaseInsensitiveComparer ());
+ foreach (DictionaryEntry de in metadata)
+ clonedMetadata.Add (de.Key, de.Value);
+ return clonedMetadata;
+ }
+
+ public void CopyMetadataTo (ITaskItem destinationItem)
+ {
+ foreach (DictionaryEntry e in metadata) {
+ destinationItem.SetMetadata ((string)e.Key, (string)e.Value);
+ }
+ }
+
+ public static explicit operator string (TaskItem taskItemToCast)
+ {
+ return taskItemToCast.ToString ();
+ }
+
+ public string GetMetadata (string metadataName)
+ {
+ switch (metadataName.ToLower ()) {
+ case "fullpath":
+ return Path.GetFullPath (itemSpec);
+ case "rootdir":
+ return "/";
+ case "filename":
+ return Path.GetFileNameWithoutExtension (itemSpec);
+ case "extension":
+ return Path.GetExtension (itemSpec);
+ case "relativedir":
+ return Path.GetDirectoryName (itemSpec);
+ case "directory":
+ return Path.GetDirectoryName (Path.GetFullPath (itemSpec));
+ case "recursivedir":
+ return recursiveDir;
+ case "identity":
+ return Path.Combine (Path.GetDirectoryName (itemSpec), Path.GetFileName (itemSpec));
+ case "modifiedtime":
+ return File.GetLastWriteTime (itemSpec).ToString ();
+ case "createdtime":
+ return File.GetCreationTime (itemSpec).ToString ();
+ case "accessedtime":
+ return File.GetLastAccessTime (itemSpec).ToString ();
+ default:
+ return (string) metadata [metadataName];
+ }
+ }
+
+ public override object InitializeLifetimeService ()
+ {
+ return null;
+ }
+
+ public void RemoveMetadata (string metadataName)
+ {
+ if (metadata.Contains (metadataName))
+ metadata.Remove (metadataName);
+ }
+
+ public void SetMetadata (string metadataName, string metadataValue)
+ {
+ if (metadata.Contains (metadataName))
+ metadata.Remove (metadataName);
+ metadata.Add (metadataName, metadataValue);
+ }
+
+ public override string ToString ()
+ {
+ return itemSpec;
+ }
+
+ public string ItemSpec {
+ get { return itemSpec; }
+ set { itemSpec = value; }
+ }
+
+ public int MetadataCount {
+ // predefined metadata
+ get { return metadata.Count + 11; }
+ }
+
+ public ICollection MetadataNames {
+ get { return metadata.Keys; }
+ }
+ }
+}
--- /dev/null
+//
+// TaskLoggingHelper.cs: Wrapper aroudn IBuildEngine.
+//
+// Author:
+// Marek Sieradzki (marek.sieradzki@gmail.com)
+//
+// (C) 2005 Marek Sieradzki
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+using System;
+using System.IO;
+using System.Resources;
+using System.Text;
+using Microsoft.Build.Framework;
+
+namespace Microsoft.Build.Utilities
+{
+ public class TaskLoggingHelper : MarshalByRefObject
+ {
+ IBuildEngine buildEngine;
+ bool hasLoggedErrors;
+ string helpKeywordPrefix;
+ string taskName;
+ ResourceManager taskResources;
+
+ public TaskLoggingHelper (ITask taskInstance)
+ {
+ this.buildEngine = taskInstance.BuildEngine;
+ }
+
+ [MonoTODO]
+ public string ExtractMessageCode (string message,
+ out string messageWithoutCodePrefix)
+ {
+ messageWithoutCodePrefix = "";
+ return "";
+ }
+
+ [MonoTODO]
+ public virtual string FormatResourceString (string resourceName,
+ params object[] args)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public virtual string FormatString (string unformatted,
+ params object[] args)
+ {
+ return "";
+ }
+
+ public void LogError (string message,
+ params object[] messageArgs)
+ {
+ BuildErrorEventArgs beea = new BuildErrorEventArgs (
+ null, null, null, 0, 0, 0, 0, message,
+ helpKeywordPrefix, null);
+ buildEngine.LogErrorEvent (beea);
+ hasLoggedErrors = true;
+ }
+
+ public void LogError (string subcategory, string errorCode,
+ string helpKeyword, string file,
+ int lineNumber, int columnNumber,
+ int endLineNumber, int endColumnNumber,
+ string message,
+ params object[] messageArgs)
+ {
+ BuildErrorEventArgs beea = new BuildErrorEventArgs (
+ subcategory, errorCode, file, lineNumber,
+ columnNumber, endLineNumber, endColumnNumber,
+ message, helpKeywordPrefix /*it's helpKeyword*/,
+ null /*it's senderName*/);
+ // FIXME: what with messageArgs?
+ buildEngine.LogErrorEvent (beea);
+ hasLoggedErrors = true;
+ }
+
+ public void LogErrorFromException (Exception e)
+ {
+ LogErrorFromException (e, false);
+ }
+
+ public void LogErrorFromException (Exception e,
+ bool showStackTrace)
+ {
+ StringBuilder sb = new StringBuilder ();
+ sb.Append (e.Message);
+ if (showStackTrace == true)
+ sb.Append (e.StackTrace);
+ BuildErrorEventArgs beea = new BuildErrorEventArgs (
+ null, null, null, 0, 0, 0, 0, sb.ToString (),
+ e.HelpLink, e.Source);
+ buildEngine.LogErrorEvent (beea);
+ hasLoggedErrors = true;
+ }
+
+ public void LogErrorFromResources (string messageResourceName,
+ params object[] messageArgs)
+ {
+ LogErrorFromResources (null, null, null, null, 0, 0, 0,
+ 0, messageResourceName, null);
+ }
+
+ public void LogErrorFromResources (string subcategoryResourceName,
+ string errorCode,
+ string helpKeyword,
+ string file, int lineNumber,
+ int columnNumber,
+ int endLineNumber,
+ int endColumnNumber,
+ string messageResourceName,
+ params object[] messageArgs)
+ {
+ BuildErrorEventArgs beea = new BuildErrorEventArgs (
+ taskResources.GetString (subcategoryResourceName),
+ errorCode, file, lineNumber, columnNumber,
+ endLineNumber, endColumnNumber,
+ taskResources.GetString (messageResourceName),
+ helpKeyword, null );
+ buildEngine.LogErrorEvent (beea);
+ hasLoggedErrors = true;
+ }
+
+ public void LogErrorWithCodeFromResources (string messageResourceName,
+ params object[] messageArgs)
+ {
+ // FIXME: there should be something different than normal
+ // LogErrorFromResources
+ LogErrorFromResources (messageResourceName, messageArgs);
+ }
+
+ public void LogErrorWithCodeFromResources (string subcategoryResourceName,
+ string file,
+ int lineNumber,
+ int columnNumber,
+ int endLineNumber,
+ int endColumnNumber,
+ string messageResourceName,
+ params object[] messageArgs)
+ {
+ // FIXME: there should be something different than normal
+ // LogErrorFromResources
+ LogErrorFromResources (subcategoryResourceName, file,
+ lineNumber, columnNumber, endLineNumber,
+ endColumnNumber, messageResourceName,
+ messageArgs);
+ }
+
+ public void LogMessage (string message,
+ params object[] messageArgs)
+ {
+ LogMessage (MessageImportance.Normal, message,
+ messageArgs);
+ }
+
+ public void LogMessage (MessageImportance importance,
+ string message,
+ params object[] messageArgs)
+ {
+ BuildMessageEventArgs bmea = new BuildMessageEventArgs (
+ message, helpKeywordPrefix, /*helpKeyword*/
+ null /*sender*/, importance);
+ // FIXME: probably messageArgs contain helpKeyword or
+ // senderName
+ buildEngine.LogMessageEvent (bmea);
+ }
+
+ public void LogMessageFromResources (string messageResourceName,
+ params object[] messageArgs)
+ {
+ LogMessage (taskResources.GetString (messageResourceName),
+ messageArgs);
+ }
+
+ public void LogMessageFromResources (MessageImportance importance,
+ string messageResourceName,
+ params object[] messageArgs)
+ {
+ LogMessage (importance, taskResources.GetString (
+ messageResourceName), messageArgs);
+ }
+
+ public bool LogMessagesFromFile (string filename)
+ {
+ return LogMessagesFromFile (filename, MessageImportance.Normal);
+ }
+
+ public bool LogMessagesFromFile (string filename,
+ MessageImportance messageImportance)
+ {
+ try {
+ StreamReader sr = new StreamReader (filename);
+ LogMessage (messageImportance, sr.ReadToEnd (),
+ null);
+ sr.Close ();
+ return true;
+ }
+ catch (Exception ex) {
+ return false;
+ }
+ }
+
+ public bool LogMessagesFromStream (TextReader stream,
+ MessageImportance messageImportance,
+ bool synchronize)
+ // FIXME: what about synchronize
+ {
+ try {
+ LogMessage (messageImportance, stream.ReadToEnd (), null);
+ return true;
+ }
+ catch (Exception ex) {
+ return false;
+ }
+ finally {
+ // FIXME: should it be done here?
+ stream.Close ();
+ }
+ }
+
+ public void LogWarning (string message,
+ params object[] messageArgs)
+ {
+ // FIXME: what about all the parameters?
+ BuildWarningEventArgs bwea = new BuildWarningEventArgs (
+ null, null, null, 0, 0, 0, 0, message,
+ helpKeywordPrefix, null);
+ buildEngine.LogWarningEvent (bwea);
+ }
+
+ public void LogWarning (string subcategory, string warningCode,
+ string helpKeyword, string file,
+ int lineNumber, int columnNumber,
+ int endLineNumber, int endColumnNumber,
+ string message,
+ params object[] messageArgs)
+ {
+ BuildWarningEventArgs bwea = new BuildWarningEventArgs (
+ subcategory, warningCode, file, lineNumber,
+ columnNumber, endLineNumber, endColumnNumber,
+ message, helpKeywordPrefix, null);
+ buildEngine.LogWarningEvent (bwea);
+ }
+
+ public void LogWarningFromException (Exception e)
+ {
+ LogWarningFromException (e, false);
+ }
+
+ public void LogWarningFromException (Exception e,
+ bool showStackTrace)
+ {
+ StringBuilder sb = new StringBuilder ();
+ sb.Append (e.Message);
+ if (showStackTrace)
+ sb.Append (e.StackTrace);
+ LogWarning (null, null, null, null, 0, 0, 0, 0,
+ sb.ToString (), null);
+ }
+
+ public void LogWarningFromResources (string messageResourceName,
+ params object[] messageArgs)
+ {
+ LogWarning (taskResources.GetString (messageResourceName),
+ messageArgs);
+ }
+
+ public void LogWarningFromResources (string subcategoryResourceName,
+ string warningCode,
+ string helpKeyword,
+ string file,
+ int lineNumber,
+ int columnNumber,
+ int endLineNumber,
+ int endColumnNumber,
+ string messageResourceName,
+ params object[] messageArgs)
+ {
+ LogWarning (taskResources.GetString (subcategoryResourceName),
+ warningCode, helpKeyword, file, lineNumber,
+ columnNumber, endLineNumber, endColumnNumber,
+ taskResources.GetString (messageResourceName),
+ messageArgs);
+ }
+
+ public void LogWarningWithCodeFromResources (string messageResourceName,
+ params object[] messageArgs)
+ {
+ // FIXME: what's different from normal logwarning?
+ LogWarningFromResources (messageResourceName, messageArgs);
+ }
+
+ public void LogWarningWithCodeFromResources (string subcategoryResourceName,
+ string file,
+ int lineNumber,
+ int columnNumber,
+ int endLineNumber,
+ int endColumnNumber,
+ string messageResourceName,
+ params object[] messageArgs)
+ {
+ LogWarningFromResources (subcategoryResourceName, file,
+ lineNumber, columnNumber, endLineNumber,
+ endColumnNumber, messageResourceName,
+ messageArgs);
+ }
+
+ protected IBuildEngine BuildEngine {
+ get {
+ return buildEngine;
+ }
+ }
+
+ public bool HasLoggedErrors {
+ get {
+ return hasLoggedErrors;
+ }
+ }
+
+ public string HelpKeywordPrefix {
+ get {
+ return helpKeywordPrefix;
+ }
+ set {
+ helpKeywordPrefix = value;
+ }
+ }
+
+ protected string TaskName {
+ get {
+ return taskName;
+ }
+ }
+
+ public ResourceManager TaskResources {
+ get {
+ return taskResources;
+ }
+ set {
+ taskResources = value;
+ }
+ }
+ }
+}
--- /dev/null
+//
+// ToolLocationHelper.cs:
+//
+// Author:
+// Marek Sieradzki (marek.sieradzki@gmail.com)
+//
+// (C) 2005 Marek Sieradzki
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+using System;
+
+namespace Microsoft.Build.Utilities
+{
+ public static class ToolLocationHelper
+ {
+ [MonoTODO]
+ public static string GetDotNetFrameworkRootRegistryKey (TargetDotNetFrameworkVersion version)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string GetDotNetFrameworkSdkInstallKeyValue (TargetDotNetFrameworkVersion version)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string GetDotNetFrameworkVersionFolderPrefix (TargetDotNetFrameworkVersion version)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string GetPathToDotNetFramework (TargetDotNetFrameworkVersion version)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string GetPathToDotNetFrameworkFile (string fileName,
+ TargetDotNetFrameworkVersion version)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string GetPathToDotNetFrameworkSdk (TargetDotNetFrameworkVersion version)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string GetPathToDotNetFrameworkSdkFile (string fileName,
+ TargetDotNetFrameworkVersion version)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string GetPathToSystemFile (string fileName) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string PathToSystem {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+ }
+}
--- /dev/null
+//
+// ToolTask.cs: Base class for command line tool tasks.
+//
+// Author:
+// Marek Sieradzki (marek.sieradzki@gmail.com)
+//
+// (C) 2005 Marek Sieradzki
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+using System;
+using System.Diagnostics;
+using System.Collections.Specialized;
+using System.Resources;
+using System.Text;
+using System.Text.RegularExpressions;
+using Microsoft.Build.Framework;
+
+namespace Microsoft.Build.Utilities
+{
+ public abstract class ToolTask : Task
+ {
+ StringDictionary environmentOverride;
+ int timeout;
+ string toolPath;
+ Process process;
+
+ static Regex regex;
+
+ protected ToolTask ()
+ : this (null, null)
+ {
+ }
+
+ protected ToolTask (ResourceManager taskResources)
+ : this (taskResources, null)
+ {
+ }
+
+ protected ToolTask (ResourceManager taskResources,
+ string helpKeywordPrefix)
+ {
+ this.TaskResources = taskResources;
+ this.HelpKeywordPrefix = helpKeywordPrefix;
+ }
+
+ static ToolTask ()
+ {
+ regex = new Regex (
+ @"^\s*"
+ + @"(((?<ORIGIN>(((\d+>)?[a-zA-Z]?:[^:]*)|([^:]*))):)"
+ + "|())"
+ + "(?<SUBCATEGORY>(()|([^:]*? )))"
+ + "(?<CATEGORY>(error|warning)) "
+ + "(?<CODE>[^:]*):"
+ + "(?<TEXT>.*)$",
+ RegexOptions.IgnoreCase);
+ }
+
+ protected virtual bool CallHostObjectToExecute ()
+ {
+ return true;
+ }
+
+ public override bool Execute ()
+ {
+ string arguments, toolFilename;
+
+ arguments = String.Concat (GenerateCommandLineCommands (), " ", GenerateResponseFileCommands ());
+ toolFilename = GenerateFullPathToTool ();
+ return RealExecute (toolFilename, arguments);
+ }
+
+ private bool RealExecute (string filename, string arguments)
+ {
+ string line;
+
+ if (filename == null)
+ throw new ArgumentNullException ("filename");
+ if (arguments == null)
+ throw new ArgumentNullException ("arguments");
+
+ process = new Process ();
+ process.StartInfo.Arguments = arguments;
+ process.StartInfo.CreateNoWindow = true;
+ process.StartInfo.FileName = filename;
+ process.StartInfo.RedirectStandardError = true;
+ process.StartInfo.RedirectStandardOutput = true;
+ process.StartInfo.UseShellExecute = false;
+
+ Log.LogMessage (MessageImportance.Low, String.Format ("Tool {0} execution started with arguments: {1}",
+ filename, arguments));
+
+ process.Start ();
+ process.WaitForExit ();
+
+ while ((line = process.StandardError.ReadLine ()) != null) {
+ HandleError (line);
+ }
+
+ Log.LogMessage (MessageImportance.Low, String.Format ("Tool {0} execution finished.", filename));
+
+ return !Log.HasLoggedErrors;
+ }
+
+ private void HandleError (string line)
+ {
+ string filename, origin, category, code, subcategory, text;
+ int lineNumber, columnNumber, endLineNumber, endColumnNumber;
+
+ Match m = regex.Match (line);
+ origin = m.Groups [regex.GroupNumberFromName ("ORIGIN")].Value;
+ category = m.Groups [regex.GroupNumberFromName ("CATEGORY")].Value;
+ code = m.Groups [regex.GroupNumberFromName ("CODE")].Value;
+ subcategory = m.Groups [regex.GroupNumberFromName ("SUBCATEGORY")].Value;
+ text = m.Groups [regex.GroupNumberFromName ("TEXT")].Value;
+
+ ParseOrigin (origin, out filename, out lineNumber, out columnNumber, out endLineNumber, out endColumnNumber);
+
+ if (category == "warning") {
+ Log.LogWarning (subcategory, code, null, filename, lineNumber, columnNumber, endLineNumber,
+ endColumnNumber, text, null);
+ } else if (category == "error") {
+ Log.LogError (subcategory, code, null, filename, lineNumber, columnNumber, endLineNumber,
+ endColumnNumber, text, null);
+ }
+ }
+
+ private void ParseOrigin (string origin, out string filename,
+ out int lineNumber, out int columnNumber,
+ out int endLineNumber, out int endColumnNumber)
+ {
+ int lParen;
+ string[] temp;
+ string[] left, right;
+
+ if (origin.IndexOf ('(') != -1 ) {
+ lParen = origin.IndexOf ('(');
+ filename = origin.Substring (0, lParen);
+ temp = origin.Substring (lParen + 1, origin.Length - lParen - 2).Split (',');
+ if (temp.Length == 1) {
+ left = temp [0].Split ('-');
+ if (left.Length == 1) {
+ lineNumber = Int32.Parse (left [0]);
+ columnNumber = 0;
+ endLineNumber = 0;
+ endColumnNumber = 0;
+ } else if (left.Length == 2) {
+ lineNumber = Int32.Parse (left [0]);
+ columnNumber = 0;
+ endLineNumber = Int32.Parse (left [1]);
+ endColumnNumber = 0;
+ } else
+ throw new Exception ("Invalid line/column format.");
+ } else if (temp.Length == 2) {
+ right = temp [1].Split ('-');
+ lineNumber = Int32.Parse (temp [0]);
+ endLineNumber = 0;
+ if (right.Length == 1) {
+ columnNumber = Int32.Parse (right [0]);
+ endColumnNumber = 0;
+ } else if (right.Length == 2) {
+ columnNumber = Int32.Parse (right [0]);
+ endColumnNumber = Int32.Parse (right [0]);
+ } else
+ throw new Exception ("Invalid line/column format.");
+ } else if (temp.Length == 4) {
+ lineNumber = Int32.Parse (temp [0]);
+ endLineNumber = Int32.Parse (temp [2]);
+ columnNumber = Int32.Parse (temp [1]);
+ endColumnNumber = Int32.Parse (temp [3]);
+ } else
+ throw new Exception ("Invalid line/column format.");
+ } else {
+ filename = origin;
+ lineNumber = 0;
+ columnNumber = 0;
+ endLineNumber = 0;
+ endColumnNumber = 0;
+ }
+ }
+
+ protected virtual string GenerateCommandLineCommands ()
+ {
+ return null;
+ }
+
+ protected abstract string GenerateFullPathToTool ();
+
+ protected virtual string GenerateResponseFileCommands ()
+ {
+ return null;
+ }
+
+ protected virtual string GetResponseFileSwitch (string responseFilePath)
+ {
+ return String.Format ("@{0}", responseFilePath);
+ }
+
+ protected virtual bool HandleTaskExecutionErrors (int exitCode,
+ bool hasTaskLoggedErrors)
+ {
+ return true;
+ }
+
+ protected virtual bool InitializeHostObject (out bool appropriateHostObjectExists,
+ out bool continueBuild)
+ {
+ appropriateHostObjectExists = (HostObject != null) ? true : false;
+ continueBuild = true;
+ return true;
+ }
+
+ protected virtual void LogToolCommand (string message)
+ {
+ }
+
+ protected virtual bool SkipTaskExecution()
+ {
+ return false;
+ }
+
+ protected virtual bool ValidateParameters()
+ {
+ return true;
+ }
+
+ protected virtual StringDictionary EnvironmentOverride
+ {
+ get { return environmentOverride; }
+ }
+
+ protected virtual Encoding ResponseFileEncoding
+ {
+ get { return Encoding.UTF8; }
+ }
+
+ protected virtual Encoding StandardErrorEncoding
+ {
+ get { return Console.Error.Encoding; }
+ }
+
+ protected virtual Encoding StandardOutputEncoding
+ {
+ get { return Console.Out.Encoding; }
+ }
+
+ public int Timeout
+ {
+ get { return timeout; }
+ set { timeout = value; }
+ }
+
+ protected abstract string ToolName
+ {
+ get;
+ }
+
+ public string ToolPath
+ {
+ get { return toolPath; }
+ set { toolPath = value; }
+ }
+ }
+}
--- /dev/null
+Microsoft.Build.Utilities/TaskItemTest.cs
--- /dev/null
+<Project name="Microsoft.Build.Utilities.Test" fileversion="2.0" language="C#" ctype="DotNetProject">
+ <Configurations active="Debug">
+ <Configuration name="Debug" ctype="DotNetProjectConfiguration">
+ <Output directory="./bin/Debug" assembly="Microsoft.Build.Utilities.Test" />
+ <Build debugmode="True" target="Library" />
+ <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" />
+ <CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+ </Configuration>
+ <Configuration name="Release" ctype="DotNetProjectConfiguration">
+ <Output directory="./bin/Release" assembly="Microsoft.Build.Utilities.Test" />
+ <Build debugmode="False" target="Library" />
+ <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" />
+ <CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+ </Configuration>
+ </Configurations>
+ <DeploymentInformation strategy="File">
+ <excludeFiles />
+ </DeploymentInformation>
+ <Contents>
+ <File name="./Microsoft.Build.Utilities/TaskItemTest.cs" subtype="Code" buildaction="Compile" />
+ </Contents>
+ <References>
+ <ProjectReference type="Project" localcopy="True" refto="Microsoft.Build.Utilities" />
+ <ProjectReference type="Project" localcopy="True" refto="Microsoft.Build.Framework" />
+ <ProjectReference type="Gac" localcopy="True" refto="nunit.framework, Version=2.2.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
+ </References>
+</Project>
\ No newline at end of file
--- /dev/null
+<Combine name="Microsoft.Build.Utilities.Test" fileversion="2.0">
+ <Configurations active="Debug">
+ <Configuration name="Debug" ctype="CombineConfiguration">
+ <Entry configuration="Debug" build="True" name="Microsoft.Build.Utilities.Test" />
+ </Configuration>
+ <Configuration name="Release" ctype="CombineConfiguration">
+ <Entry configuration="Debug" build="True" name="Microsoft.Build.Utilities.Test" />
+ </Configuration>
+ </Configurations>
+ <StartMode startupentry="Microsoft.Build.Utilities.Test" single="True">
+ <Execute type="None" entry="Microsoft.Build.Utilities.Test" />
+ </StartMode>
+ <Entries>
+ <Entry filename="./Microsoft.Build.Utilities.Test.mdp" />
+ </Entries>
+</Combine>
\ No newline at end of file
--- /dev/null
+//
+// TaskItemTest.cs:
+//
+// Author:
+// Marek Sieradzki (marek.sieradzki@gmail.com)
+//
+// (C) 2005 Marek Sieradzki
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+using Microsoft.Build.Framework;
+using Microsoft.Build.Utilities;
+using NUnit.Framework;
+
+[TestFixture]
+public class TaskItemTest {
+
+ ITaskItem item,item1,item2;
+
+ [SetUp]
+ public void SetUp ()
+ {
+ }
+
+ [Test]
+ public void SetMetadataTest ()
+ {
+ item = new TaskItem ("itemSpec");
+ item.SetMetadata ("Metadata", "Value");
+ Assert.AreEqual (item.MetadataCount, 12, "MetadataCount");
+ }
+
+ [Test]
+ public void GetMetadataTest ()
+ {
+ item = new TaskItem ("itemSpec");
+ item.SetMetadata ("Metadata", "Value");
+ Assert.AreEqual (item.GetMetadata ("Metadata"), "Value", "Metadata value");
+ }
+
+ [Test]
+ public void CopyMetadataToTest ()
+ {
+ item1 = new TaskItem ("itemSpec");
+ item2 = new TaskItem ("itemSpec");
+ item1.SetMetadata ("1","2");
+ item1.CopyMetadataTo (item2);
+ Assert.AreEqual (item2.GetMetadata ("1"), item1.GetMetadata ("1"),"Metadata in items");
+ }
+}
\ No newline at end of file