当前位置: 首页>>代码示例>>C#>>正文


C# TaskLoggingHelper.LogError方法代码示例

本文整理汇总了C#中Microsoft.Build.Utilities.TaskLoggingHelper.LogError方法的典型用法代码示例。如果您正苦于以下问题:C# TaskLoggingHelper.LogError方法的具体用法?C# TaskLoggingHelper.LogError怎么用?C# TaskLoggingHelper.LogError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Build.Utilities.TaskLoggingHelper的用法示例。


在下文中一共展示了TaskLoggingHelper.LogError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidationPattern

            public ValidationPattern(ITaskItem item, TaskLoggingHelper log)
            {
                string idRegex = item.GetMetadata("IdentityRegex");
                if (string.IsNullOrEmpty(idRegex))
                {
                    // Temporarily support reading the regex from the Include/ItemSpec for backwards compatibility
                    // when the IdentityRegex isn't specified. This can be removed once all consumers are using IdentityRegex.
                    idRegex = item.ItemSpec;
                }

                _idPattern = new Regex(idRegex);
                _expectedVersion = item.GetMetadata("ExpectedVersion");
                _expectedPrerelease = item.GetMetadata("ExpectedPrerelease");
                _log = log;

                if (string.IsNullOrWhiteSpace(_expectedVersion))
                {
                    if (string.IsNullOrWhiteSpace(_expectedPrerelease))
                    {
                        _log.LogError(
                            "Can't find ExpectedVersion or ExpectedPrerelease metadata on item {0}",
                            item.ItemSpec);
                    }
                }
                else if (!string.IsNullOrWhiteSpace(_expectedPrerelease))
                {
                    _log.LogError(
                        "Both ExpectedVersion and ExpectedPrerelease metadata found on item {0}, but only one permitted",
                        item.ItemSpec);
                }
            }
开发者ID:dsgouda,项目名称:buildtools,代码行数:31,代码来源:ValidateProjectDependencyVersions.cs

示例2: Parse

        public bool Parse(string antBuildPath, string antBuildType, TaskLoggingHelper log, bool outputInQuotes)
        {
            // Ant build directory check
            if (Directory.Exists(antBuildPath) == false)
            {
                log.LogError("Ant Build Path '" + antBuildPath + "' does not exist");
                return false;
            }

            // Check that the build.xml exists
            string buildXml = Path.GetFullPath(antBuildPath + "\\build.xml");
            if (File.Exists(buildXml) == false)
            {
                log.LogError("build.xml '" + buildXml + "' does not exist");
                return false;
            }

            // Check that the AndroidManifest.xml exists
            string manifestXml = Path.GetFullPath(antBuildPath + "\\AndroidManifest.xml");
            if (File.Exists(manifestXml) == false)
            {
                log.LogError("AndroidManifest.xml '" + manifestXml + "' does not exist");
                return false;
            }

            // Parse the xml to grab the finished apk path
            if (ParseBuildXml(buildXml))
            {
                if (antBuildType.ToLower() == "debug")
                {
                    OutputFile = Path.GetFullPath(antBuildPath + "\\" + BUILD_BIN_PATH + "\\" + ApkName + "-debug.apk");
                }
                else
                {
                    OutputFile = Path.GetFullPath(antBuildPath + "\\" + BUILD_BIN_PATH + "\\" + ApkName + "-release.apk");
                }

                if ( outputInQuotes )
                {
                    OutputFile = "\"" + OutputFile + "\"";
                }
            }
            else
            {
                // Parse failed, oh dear.
                log.LogError("Failed parsing '" + buildXml + "'");
                return false;
            }

            if (ParseAndroidManifestXml(manifestXml) == false)
            {
                // Parse failed, oh dear.
                log.LogError("Failed parsing '" + manifestXml + "'");
                return false;
            }

            return true;
        }
开发者ID:ShaneeN,项目名称:vs-android,代码行数:58,代码来源:AntBuildParser.cs

示例3: GetAppBuildOrder

        public IEnumerable<string> GetAppBuildOrder(string sourceDirectory, string startAppPath, string uniqueSourceDirectoryPath, TaskLoggingHelper log)
        {
            _log = log;
            _uniqueSourceDirectoryPath = uniqueSourceDirectoryPath;
            var sourceDirectoryPath = sourceDirectory.Trim('\'', '"');
            var appList = GetAppListWithReferences(sourceDirectoryPath);

            var appPath = startAppPath.Trim('\'', '"');
            var startApps = appPath.Split('|').ToList();
            foreach (var app in startApps)
            {
                if (!string.IsNullOrEmpty(app))
                {
                    _log.LogMessage("Application path: {0}", app);
                    var startApp = appList[Path.GetFullPath(app.ToUpper().Replace(sourceDirectoryPath.ToUpper(), _uniqueSourceDirectoryPath)).ToUpper()];
                    if (startApp == null)
                    {
                        log.LogError("Application {0} could not be found.", app);
                    }
                    else
                    {
                        _orderedAppList.Add(Path.GetFullPath(app.ToUpper().Replace(sourceDirectoryPath.ToUpper(), _uniqueSourceDirectoryPath)).ToUpper());
                        LoopReferences(startApp, appList);
                    }
                }
            }

            _orderedAppList.ForEach(a => _log.LogMessage(a));

            return _orderedAppList;
        }
开发者ID:nickvane,项目名称:AionMsBuildTasks,代码行数:31,代码来源:AppOrderer.cs

示例4: HandleIntegerList

		private static bool HandleIntegerList(dynamic scTask, IList<int> targetCollection, string value, string itemName, TaskLoggingHelper log) {
			if (!string.IsNullOrEmpty(value)) {
				foreach (var s in value.Split(new[] { ';', ',' }).Select(s => s.Trim()).Where(s => s != "")) {
					int w;
					if (!int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out w)) {
						log.LogError("Invalid number " + s + " in " + itemName);
						return false;
					}
					if (!targetCollection.Contains(w))
						targetCollection.Add(w);
				}
			}
			return true;
		}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:14,代码来源:Worker.cs

示例5: ValidationPattern

            public ValidationPattern(ITaskItem item, TaskLoggingHelper log)
            {
                _idPattern = new Regex(item.ItemSpec);
                _expectedVersion = item.GetMetadata("ExpectedVersion");
                _expectedPrerelease = item.GetMetadata("ExpectedPrerelease");
                _log = log;

                if (string.IsNullOrWhiteSpace(_expectedVersion))
                {
                    if (string.IsNullOrWhiteSpace(_expectedPrerelease))
                    {
                        _log.LogError(
                            "Can't find ExpectedVersion or ExpectedPrerelease metadata on item {0}",
                            item.ItemSpec);
                    }
                }
                else if (!string.IsNullOrWhiteSpace(_expectedPrerelease))
                {
                    _log.LogError(
                        "Both ExpectedVersion and ExpectedPrerelease metadata found on item {0}, but only one permitted",
                        item.ItemSpec);
                }
            }
开发者ID:TerabyteX,项目名称:buildtools,代码行数:23,代码来源:ValidateProjectDependencyVersions.cs

示例6: CollectTargets

		public CollectTargets(TaskLoggingHelper log)
		{
			Log = log;
			// Get the parent directory of the running program.  We assume that
			// this is the root of the FieldWorks repository tree.
			var fwrt = BuildUtils.GetAssemblyFolder();
			while (!Directory.Exists(Path.Combine(fwrt, "Build")) || !Directory.Exists(Path.Combine(fwrt, "Src")))
			{
				fwrt = Path.GetDirectoryName(fwrt);
				if (fwrt == null)
				{
					Log.LogError("Error pulling the working folder from the running assembly.");
					break;
				}
			}
			m_fwroot = fwrt;
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:17,代码来源:CollectTargets.cs

示例7: InstallPackages

 public static bool InstallPackages(string packagesDirectory, string packagesConfigPath, string nugetExePath, TaskLoggingHelper log)
 {
     var nugetArguments = @"install -o " + packagesDirectory + " -Prerelease -NonInteractive " + packagesConfigPath;
     log.LogMessage("Installing: " + nugetExePath + " " + nugetArguments);
     ProcessStartInfo psi = new ProcessStartInfo();
     psi.UseShellExecute = false;
     psi.FileName = nugetExePath;
     psi.Arguments = nugetArguments;
     psi.CreateNoWindow = true;
     var process = Process.Start(psi);
     if (!process.WaitForExit(20000))
     {
         log.LogError("Packages installation timed out.");
         return false;
     }
     return true;
 }
开发者ID:ryaneliseislalom,项目名称:corefxlab,代码行数:17,代码来源:PackageReader.cs

示例8: CreateJavaSources

 public static bool CreateJavaSources(TaskLoggingHelper log, IEnumerable<TypeDefinition> javaTypes, string outputPath, bool useSharedRuntime, bool generateOnCreateOverrides, bool hasExportReference)
 {
     bool ok = true;
     foreach (var t in javaTypes) {
         try {
             GenerateJavaSource (log, t, outputPath, useSharedRuntime, generateOnCreateOverrides, hasExportReference);
         } catch (XamarinAndroidException xae) {
             ok = false;
             log.LogError (
                     subcategory:      "",
                     errorCode:        "XA" + xae.Code,
                     helpKeyword:      string.Empty,
                     file:             xae.SourceFile,
                     lineNumber:       xae.SourceLine,
                     columnNumber:     0,
                     endLineNumber:    0,
                     endColumnNumber:  0,
                     message:          xae.MessageWithoutCode,
                     messageArgs:      new object [0]
             );
         }
     }
     return ok;
 }
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:24,代码来源:Generator.cs

示例9: Initialize

    public bool Initialize(string taskName, IDictionary<string, TaskPropertyInfo> parameterGroup, string taskBody, IBuildEngine taskFactoryLoggingHost)
    {
      TaskLoggingHelper log = new TaskLoggingHelper(taskFactoryLoggingHost, taskName);
        
      // We use the property group for the declaration
      taskProperties = (from c in parameterGroup select c.Value).ToArray();

      // Compile chunk
      try
      {
        log.LogMessage("Compile script.");
        task = lua.CompileChunk(taskBody, taskName, LuaDeskop.StackTraceCompileOptions, 
          new KeyValuePair<string, Type>("engine", typeof(IBuildEngine)), 
          new KeyValuePair<string, Type>("log", typeof(TaskLoggingHelper))
        );
        
        return true;
      }
      catch (LuaParseException e)
      {
        log.LogError("{0} (at line {1},{2})", e.Message, taskName, e.Line);
        return false;
      }
    } // func Initialize
开发者ID:edisonh,项目名称:neolua,代码行数:24,代码来源:LuaTaskFactory.cs

示例10: Bind

        public static bool Bind(TaskLoggingHelper log, XmlReader modelReader, XmlReader viewModelReader, XmlWriter viewWriter, Action<object, XsltMessageEncounteredEventArgs> messageAction = null)
        {
            XmlDocument viewModelDocument = new XmlDocument();
            try
            {
                viewModelDocument.Load(viewModelReader);
            }
            catch (Exception x)
            {
                log.LogError("View Model: {0}", x.Message);
                return false;
            }

            XmlDocument modelDocument = new XmlDocument();

            try
            {
                modelDocument.Load(modelReader);
            }
            catch (Exception x)
            {
                log.LogError("Model: {0}", x.Message);
                return false;
            }

            using (StringReader dummyReader = new StringReader("<dummy/>"))
            {
                XslTransforms.BindTransform.Apply(
                    XmlReader.Create(dummyReader),
                    viewWriter,
                    messageAction: messageAction,
                    parameters: new[] {
                    new XslTransforms.Parameter("ViewModel", "", viewModelDocument),
                    new XslTransforms.Parameter("Model", "", modelDocument)});
            }
            return true;
        }
开发者ID:automatonic,项目名称:exult,代码行数:37,代码来源:XslTranforms.cs

示例11: ExecuteWithLogging

        /// <summary>
        /// Executes a tool, logs standard error and a nonzero exit code as errors, returns the output and optionally logs that
        /// as well.
        /// </summary>
        /// <param name="log">used for logging</param>
        /// <param name="executable">the name of the executable</param>
        /// <param name="args">the command line arguments</param>
        /// <param name="logOutput">should we log the output in real time</param>
        /// <returns>the output of the tool</returns>
        public static string ExecuteWithLogging(TaskLoggingHelper log, string executable, string args, bool logOutput)
        {
            if (log == null)
            {
                throw new ArgumentNullException("log");
            }

            log.LogMessage(MessageImportance.Low, "Executing tool: {0} {1}", executable, args);

            var exec = new ShellWrapper(executable, args);

            // stderr is logged as errors
            exec.ErrorDataReceived += (sender, e) =>
            {
                if (e.Data != null)
                {
                    log.LogError(e.Data);
                }
            };

            // stdout is logged normally if requested
            if (logOutput)
            {
                exec.OutputDataReceived += (sender, e) =>
                {
                    if (e.Data != null)
                    {
                        log.LogMessage(MessageImportance.Normal, e.Data);
                    }
                };
            }

            // execute the process
            exec.Execute();

            // check the exit code
            if (exec.ExitCode != 0)
            {
                log.LogError("The tool {0} exited with error code {1}", executable, exec.ExitCode);
            }

            return exec.StandardOutput;
        }
开发者ID:simondmorias,项目名称:MSBuildExtensionPack,代码行数:52,代码来源:Utilities.cs

示例12: ApiInvoke

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Dynamically invokes <paramref name="methodName"/> in dll <paramref name="fileName"/>.
		/// </summary>
		/// <param name="log">Log helper</param>
		/// <param name="fileName">Name of the dll.</param>
		/// <param name="delegateSignatureType">Signature of the method.</param>
		/// <param name="methodName">Name of the method</param>
		/// <param name="args">Arguments to pass to <paramref name="methodName"/>.</param>
		/// ------------------------------------------------------------------------------------
		private static void ApiInvoke(TaskLoggingHelper log, string fileName,
			Type delegateSignatureType, string methodName, params object[] args)
		{
			if (!File.Exists(fileName))
				return;
			fileName = Path.GetFullPath(fileName);
			IntPtr hModule = LoadLibrary(fileName);
			if (hModule == IntPtr.Zero)
			{
				var errorCode = Marshal.GetLastWin32Error();
				log.LogError("Failed to load library {0} for {1} with error code {2}", fileName, methodName,
					errorCode);
				return;
			}

			try
			{
				IntPtr method = GetProcAddress(hModule, methodName);
				if (method == IntPtr.Zero)
					return;

				Marshal.GetDelegateForFunctionPointer(method, delegateSignatureType).DynamicInvoke(args);
			}
			catch (Exception e)
			{
				log.LogError("RegHelper.ApiInvoke failed getting function pointer for {0}: {1}",
					methodName, e);
			}
			finally
			{
				FreeLibrary(hModule);
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:43,代码来源:RegHelper.cs

示例13: ValidNonNull

    private bool ValidNonNull(string name, object value, TaskLoggingHelper log)
    {
      Contract.Requires(name != null);
      Contract.Ensures(!Contract.Result<bool>() || (value != null));
      Contract.Ensures(Contract.Result<bool>() || (value == null));

      if (value == null)
      {
        if (log != null)
        {
          log.LogError("Parameter '{0}' must be non-empty", name);
        }
        return false;
      }
      return true;
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:16,代码来源:MsBuildTask.cs

示例14: AppendExtensions

        /// <summary>
        /// Append each of the define constants to the command line.
        /// </summary>
        /// <param name="commandLine">Command line builder.</param>
        internal static void AppendExtensions(CommandLineBuilder commandLine, ITaskItem[] extensions, TaskLoggingHelper log)
        {
            if (extensions == null)
            {
                // No items
                return;
            }

            for (int i = 0; i < extensions.Length; i++)
            {
                string className = extensions[i].GetMetadata("Class");
                if (String.IsNullOrEmpty(className))
                {
                    log.LogError(String.Format("Missing the required property 'Class' for the extension {0}", extensions[i].ItemSpec));
                }

                commandLine.AppendSwitchUnquotedIfNotNull("-ext ", String.Concat(className, ",", extensions[i].ItemSpec));
            }
        }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:23,代码来源:Candle.cs

示例15: GetOptions

		private static CompilerOptions GetOptions(dynamic taskOptions, TaskLoggingHelper log) {
			var result = new CompilerOptions();

			result.KeyContainer          =  taskOptions.KeyContainer;
			result.KeyFile               =  taskOptions.KeyFile;
			result.MinimizeScript        = !taskOptions.EmitDebugInformation;
			result.DocumentationFile     =  taskOptions.DocumentationFile;
			result.OutputAssemblyPath    =  taskOptions.OutputAssembly;
			result.OutputScriptPath      =  taskOptions.OutputScript;
			result.TreatWarningsAsErrors =  taskOptions.TreatWarningsAsErrors;
			result.WarningLevel          =  taskOptions.WarningLevel;
			result.AlreadyCompiled       =  taskOptions.AlreadyCompiled;

			result.EntryPointClass = taskOptions.MainEntryPoint;
			if (!string.IsNullOrEmpty(taskOptions.TargetType)) {
				switch ((string)taskOptions.TargetType.ToLowerInvariant()) {
					case "exe":
					case "winexe":
						result.HasEntryPoint = true;
						break;
					case "library":
					case "module":
						result.HasEntryPoint = false;
						break;
					default:
						log.LogError("Invalid target type (must be exe, winexe, library or module).");
						return null;
				}
			}
			else {
				result.HasEntryPoint = false;
			}

			if (taskOptions.WarningLevel < 0 || taskOptions.WarningLevel > 4) {
				log.LogError("Warning level must be between 0 and 4.");
				return null;
			}

			if (taskOptions.AdditionalLibPaths != null)
				result.AdditionalLibPaths.AddRange(taskOptions.AdditionalLibPaths);

			if (taskOptions.DefineConstants != null)
				result.DefineConstants.AddRange(((string)taskOptions.DefineConstants).Split(';').Select(s => s.Trim()).Where(s => s != ""));

			if (!HandleIntegerList(taskOptions, result.DisabledWarnings, taskOptions.DisabledWarnings, "DisabledWarnings", log))
				return null;
			if (!HandleIntegerList(taskOptions, result.WarningsAsErrors, taskOptions.WarningsAsErrors, "WarningsAsErrors", log))
				return null;
			if (!HandleIntegerList(taskOptions, result.WarningsNotAsErrors, taskOptions.WarningsNotAsErrors, "WarningsNotAsErrors", log))
				return null;

			if (taskOptions.References != null) {
				foreach (ITaskItem r in taskOptions.References) {
					string alias = r.GetMetadata("Aliases");
					result.References.Add(new Reference(r.ItemSpec, !string.IsNullOrWhiteSpace(alias) ? alias : null));
				}
			}

			if (taskOptions.Sources != null) {
				foreach (ITaskItem s in taskOptions.Sources) {
					result.SourceFiles.Add(s.ItemSpec);
				}
			}

			if (taskOptions.Resources != null) {
				foreach (ITaskItem r in taskOptions.Resources) {
					string name = r.GetMetadata("LogicalName");
					string access = r.GetMetadata("Access");
					result.EmbeddedResources.Add(new EmbeddedResource(r.ItemSpec, !string.IsNullOrWhiteSpace(name) ? name : Path.GetFileName(r.ItemSpec), !string.Equals(access, "private", StringComparison.OrdinalIgnoreCase)));
				}
			}

			return result;
		}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:74,代码来源:Worker.cs


注:本文中的Microsoft.Build.Utilities.TaskLoggingHelper.LogError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。