protected virtual bool ForcedRebuildRequired() { string path; try { path = TLogCommandFile.GetMetadata("FullPath"); } catch (Exception ex) { if (!(ex is InvalidOperationException) && !(ex is NullReferenceException)) { throw; } Log.LogWarningWithCodeFromResources( nameof(Strings.TrackedToolTask_RebuildingDueToInvalidTLog), ex.Message); return(true); } if (!File.Exists(path)) { Log.LogMessageFromResources( MessageImportance.Low, nameof(Strings.TrackedToolTask_RebuildingNoCommandTLog), TLogCommandFile.GetMetadata("FullPath")); return(true); } return(false); }
protected void WriteSourcesToOptionsTable( IDictionary <string, string> sourcesToOptions) { using var writer = CreateUnicodeWriter(TLogCommandFile.GetMetadata("FullPath")); foreach (KeyValuePair <string, string> pair in sourcesToOptions) { writer.WriteLine("^" + pair.Key); writer.WriteLine(ApplyPrecompareCommandFilter(pair.Value)); } }
protected IDictionary <string, string> MapSourcesToOptions() { var sourceMap = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); string metadata = TLogCommandFile.GetMetadata("FullPath"); if (!File.Exists(metadata)) { return(sourceMap); } using var reader = File.OpenText(metadata); bool invalidTLog = false; string source = string.Empty; for (string line = reader.ReadLine(); line != null; line = reader.ReadLine()) { if (line.Length == 0) { invalidTLog = true; break; } if (line[0] == '^') { if (line.Length == 1) { invalidTLog = true; break; } source = line.Substring(1); } else { if (!sourceMap.ContainsKey(source)) { sourceMap[source] = line; } else { sourceMap[source] += "\r\n" + line; } } } if (invalidTLog) { Log.LogWarningWithCodeFromResources( nameof(Strings.TrackedToolTask_RebuildingDueToInvalidTLogContents), metadata); sourceMap = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); } return(sourceMap); }
protected virtual void OutputCommandTLog(ITaskItem[] compiledSources) { string fullpath = TLogCommandFile.GetMetadata("FullPath"); using (var writer = new StreamWriter(fullpath, false, Encoding.Unicode)) { string cmds = TLogCommandForSource(Sources[0]); string sourcePath = ""; foreach (ITaskItem source in Sources) { if (sourcePath != "") { sourcePath += "|"; } sourcePath += Path.GetFullPath(source.ItemSpec).ToUpperInvariant(); } writer.WriteLine("^" + sourcePath); writer.WriteLine(cmds); } }