Example #1
0
        protected bool PrepareTaskAssembly(out Type taskType)
        {
            taskType = null;
            Assembly assembly = string.IsNullOrEmpty(TaskAssemblyName) ?
                                typeof(MultiToolTask).Assembly :
                                Assembly.LoadFrom(TaskAssemblyName);

            if (assembly == null)
            {
                Log.LogErrorWithCodeFromResources("General.InvalidValue",
                                                  TaskAssemblyName.GetType().Name,
                                                  GetType().Name);
                return(false);
            }
            taskType = assembly.GetType(TaskName);
            if (taskType == null)
            {
                Log.LogErrorWithCodeFromResources("General.InvalidValue",
                                                  TaskName.GetType().Name,
                                                  GetType().Name);
                return(false);
            }
            object obj = Activator.CreateInstance(taskType);

            if (new TrackedVCToolTaskInterfaceHelper(obj, taskType) == null)
            {
                Log.LogErrorWithCodeFromResources("General.InvalidValue",
                                                  TaskName.GetType().Name,
                                                  GetType().Name);
                return(false);
            }
            if (SchedulerVerbose)
            {
                Log.LogMessageFromResources("MultiTool.TaskFound", TaskName);
            }
            if (string.IsNullOrEmpty(ToolExe))
            {
                ToolExe = (obj as ToolTask).ToolExe;
            }
            var pathToTool = ComputePathToTool(ToolPath, ToolExe);

            if (!string.IsNullOrEmpty(pathToTool))
            {
                ToolPath = Path.GetDirectoryName(pathToTool);
                ToolExe  = Path.GetFileName(pathToTool);
            }
            if (SchedulerVerbose)
            {
                Log.LogMessageFromResources("MultiTool.BuildingWith", ToolExe);
            }
            return(true);
        }