本文整理汇总了C#中Microsoft.Build.Utilities.TaskLoggingHelper.LogMessageFromText方法的典型用法代码示例。如果您正苦于以下问题:C# TaskLoggingHelper.LogMessageFromText方法的具体用法?C# TaskLoggingHelper.LogMessageFromText怎么用?C# TaskLoggingHelper.LogMessageFromText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Utilities.TaskLoggingHelper
的用法示例。
在下文中一共展示了TaskLoggingHelper.LogMessageFromText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public bool Execute()
{
//set up support for logging
TaskLoggingHelper loggingHelper = new TaskLoggingHelper(this);
loggingHelper.LogMessageFromText(
"Hello MSBuild", MessageImportance.High);
return true;
}
示例2: GetTableWithEscaping
internal static bool GetTableWithEscaping(TaskLoggingHelper log, string parameterName, string syntaxName, string[] propertyNameValueStrings, out Hashtable finalPropertiesTable)
{
finalPropertiesTable = null;
if (propertyNameValueStrings != null)
{
finalPropertiesTable = new Hashtable(StringComparer.OrdinalIgnoreCase);
List<PropertyNameValuePair> list = new List<PropertyNameValuePair>();
foreach (string str in propertyNameValueStrings)
{
int index = str.IndexOf('=');
if (index != -1)
{
string propertyName = str.Substring(0, index).Trim();
string propertyValue = Microsoft.Build.Shared.EscapingUtilities.Escape(str.Substring(index + 1).Trim());
if (propertyName.Length == 0)
{
if (log != null)
{
log.LogErrorWithCodeFromResources("General.InvalidPropertyError", new object[] { syntaxName, str });
}
return false;
}
list.Add(new PropertyNameValuePair(propertyName, propertyValue));
}
else if (list.Count > 0)
{
string str4 = Microsoft.Build.Shared.EscapingUtilities.Escape(str.Trim());
list[list.Count - 1].Value.Append(';');
list[list.Count - 1].Value.Append(str4);
}
else
{
if (log != null)
{
log.LogErrorWithCodeFromResources("General.InvalidPropertyError", new object[] { syntaxName, str });
}
return false;
}
}
if (log != null)
{
log.LogMessageFromText(parameterName, MessageImportance.Low);
}
foreach (PropertyNameValuePair pair in list)
{
finalPropertiesTable[pair.Name] = pair.Value.ToString();
if (log != null)
{
log.LogMessageFromText(string.Format(CultureInfo.InvariantCulture, " {0}={1}", new object[] { pair.Name, pair.Value.ToString() }), MessageImportance.Low);
}
}
}
return true;
}
示例3: foreach
/// <summary>
///
/// </summary>
/// <returns>True if the operation was successful</returns>
internal static bool ExecuteTargets
(
ITaskItem[] projects,
Hashtable propertiesTable,
string[] undefineProperties,
ArrayList targetLists,
bool stopOnFirstFailure,
bool rebaseOutputs,
IBuildEngine3 buildEngine,
TaskLoggingHelper log,
ArrayList targetOutputs,
bool useResultsCache,
bool unloadProjectsOnCompletion,
string toolsVersion
)
{
bool success = true;
// We don't log a message about the project and targets we're going to
// build, because it'll all be in the immediately subsequent ProjectStarted event.
string[] projectDirectory = new string[projects.Length];
string[] projectNames = new string[projects.Length];
string[] toolsVersions = new string[projects.Length];
IList<IDictionary<string, ITaskItem[]>> targetOutputsPerProject = null;
IDictionary[] projectProperties = new IDictionary[projects.Length];
List<string>[] undefinePropertiesPerProject = new List<string>[projects.Length];
for (int i = 0; i < projectNames.Length; i++)
{
projectNames[i] = null;
projectProperties[i] = propertiesTable;
if (projects[i] != null)
{
// Retrieve projectDirectory only the first time. It never changes anyway.
string projectPath = FileUtilities.AttemptToShortenPath(projects[i].ItemSpec);
projectDirectory[i] = Path.GetDirectoryName(projectPath);
projectNames[i] = projects[i].ItemSpec;
toolsVersions[i] = toolsVersion;
// If the user specified a different set of global properties for this project, then
// parse the string containing the properties
if (!String.IsNullOrEmpty(projects[i].GetMetadata("Properties")))
{
Hashtable preProjectPropertiesTable;
if (!PropertyParser.GetTableWithEscaping
(log, ResourceUtilities.FormatResourceString("General.OverridingProperties", projectNames[i]), "Properties", projects[i].GetMetadata("Properties").Split(';'),
out preProjectPropertiesTable)
)
{
return false;
}
projectProperties[i] = preProjectPropertiesTable;
}
if (undefineProperties != null)
{
undefinePropertiesPerProject[i] = new List<string>(undefineProperties);
}
// If the user wanted to undefine specific global properties for this project, parse
// that string and remove them now.
string projectUndefineProperties = projects[i].GetMetadata("UndefineProperties");
if (!String.IsNullOrEmpty(projectUndefineProperties))
{
string[] propertiesToUndefine = projectUndefineProperties.Split(new char[] { ';' });
if (undefinePropertiesPerProject[i] == null)
{
undefinePropertiesPerProject[i] = new List<string>(propertiesToUndefine.Length);
}
if (log != null && propertiesToUndefine.Length > 0)
{
log.LogMessageFromResources(MessageImportance.Low, "General.ProjectUndefineProperties", projectNames[i]);
foreach (string property in propertiesToUndefine)
{
undefinePropertiesPerProject[i].Add(property);
log.LogMessageFromText(String.Format(CultureInfo.InvariantCulture, " {0}", property), MessageImportance.Low);
}
}
}
// If the user specified a different set of global properties for this project, then
// parse the string containing the properties
if (!String.IsNullOrEmpty(projects[i].GetMetadata("AdditionalProperties")))
{
Hashtable additionalProjectPropertiesTable;
if (!PropertyParser.GetTableWithEscaping
(log, ResourceUtilities.FormatResourceString("General.AdditionalProperties", projectNames[i]), "AdditionalProperties", projects[i].GetMetadata("AdditionalProperties").Split(';'),
out additionalProjectPropertiesTable)
)
{
return false;
}
//.........这里部分代码省略.........