private TrackedVCToolTaskInterfaceHelper CreateTask(Type taskType, List <ITaskItem> taskItems, string currentDirectory, string[] environmentVariables) { var interfaceHelper = new TrackedVCToolTaskInterfaceHelper(Activator.CreateInstance(taskType), taskType); PopulateTaskFromSourceItems(taskType, taskItems, interfaceHelper); SetTaskDefaults(interfaceHelper); interfaceHelper.EffectiveWorkingDirectory = currentDirectory; interfaceHelper.EnvironmentVariables = environmentVariables; interfaceHelper.PostBuildTrackingCleanup = false; return(interfaceHelper); }
private void CheckCommandLineOutOfDate(bool minimalRebuldFromTracking, List <ITaskItem> taskItems, string sources, TrackedVCToolTaskInterfaceHelper task, string cmdLine, ref bool toBeCompiled, ref bool outOfDateCommandLine) { if ((SourcesCompiled != null && minimalRebuldFromTracking) && SourcesCompiled.Intersect(taskItems.ToArray()).Count() != taskItems.Count) { string existingCmdLine = null; sourcesToCommandLines.TryGetValue(sources, out existingCmdLine); if (existingCmdLine != null) { existingCmdLine = task.ApplyPrecompareCommandFilter(existingCmdLine); } if (existingCmdLine == null || !cmdLine.Equals(existingCmdLine, StringComparison.Ordinal)) { if (existingCmdLine != null && SchedulerVerbose) { Log.LogMessageFromResources("MultiTool.SourceNotMatchCommand", sources); } sourcesToCommandLines[sources] = cmdLine; toBeCompiled = true; outOfDateCommandLine = true; } } else { if (SchedulerVerbose) { Log.LogMessageFromResources("MultiTool.SourceOutOfDate", sources); } sourcesToCommandLines[sources] = cmdLine; toBeCompiled = true; } }
private string GenerateCommandLine(TrackedVCToolTaskInterfaceHelper task, ref System.Text.StringBuilder strBuilder, List <ITaskItem> taskItems, string currentDirectory) { var interfaceHelper2 = task; // is this needed? var cmdLineWithoutSwitches = interfaceHelper2.GenerateCommandLineExceptSwitches(new string[1] { SourcesPropertyName }, CommandLineFormat.ForTracking, EscapeFormat.Default); strBuilder.Clear(); foreach (var item in taskItems) { strBuilder.Append(Path.Combine(currentDirectory, item.ItemSpec).ToUpperInvariant()); strBuilder.Append(" "); } string cmdLine = interfaceHelper2.ApplyPrecompareCommandFilter(cmdLineWithoutSwitches) + " " + strBuilder.ToString(); return(cmdLine); }
protected int PopulateTaskFromSourceItems(Type taskType, List <ITaskItem> sources, TrackedVCToolTaskInterfaceHelper schedulingTask) { int propertiesSet = 0; PropertyInfo[] properties = taskType.GetProperties(); foreach (var propertyInfo in properties) { string propertyName = propertyInfo.Name; if (!string.IsNullOrEmpty(propertyName)) { if (string.Compare(schedulingTask.SourcesPropertyName, propertyName, StringComparison.OrdinalIgnoreCase) == 0) { if (propertyInfo.PropertyType == typeof(ITaskItem)) { if (sources.Count == 1) { propertyInfo.SetValue(schedulingTask.Instance, sources[0]); } else { throw new InvalidCastException("Unable to cast " + propertyInfo.PropertyType.ToString() + " to ITaskItem[]."); } } else if (propertyInfo.PropertyType == typeof(ITaskItem[])) { propertyInfo.SetValue(schedulingTask.Instance, sources.ToArray()); } ++propertiesSet; } else { string metadata = sources[0].GetMetadata(propertyName); if (!string.IsNullOrEmpty(metadata)) { if (propertyInfo.PropertyType == typeof(bool)) { propertyInfo.SetValue(schedulingTask.Instance, bool.Parse(metadata)); } else if (propertyInfo.PropertyType == typeof(int)) { propertyInfo.SetValue(schedulingTask.Instance, int.Parse(metadata)); } else if (propertyInfo.PropertyType == typeof(string)) { propertyInfo.SetValue(schedulingTask.Instance, metadata); } else if (propertyInfo.PropertyType == typeof(string[])) { string[] stringArrayValue = (from v in metadata.Split(StringArraySplitter, StringSplitOptions.RemoveEmptyEntries) select v.Trim()) .ToArray(); propertyInfo.SetValue(schedulingTask.Instance, stringArrayValue); } else { throw new InvalidCastException("Unable to cast " + propertyInfo.PropertyType.ToString() + " to bool, int, string or string[]."); } ++propertiesSet; } } } else { continue; } } return(propertiesSet); }