Exemplo n.º 1
0
        public bool Execute()
        {
            // The equivalent of Main() for console access
            ExitCode result = Utility.ExitCode.GeneralFailure;

            IArgumentProvider argumentProvider = new BuildArgumentParser(this.TaskName, this.Targets, this.Options, fileService);

            using (ITaskService taskService = this.GetTaskService(ref argumentProvider))
            {
                BuildTaskExecution execution = new BuildTaskExecution(
                    buildEngine: this.BuildEngine,
                    outputHandler: this,
                    argumentProvider: argumentProvider,
                    taskRegistry: taskService.TaskRegistry);

                // We need to be on an STA thread to interact with the clipboard. We don't
                // control the main thread when executed by MSBuild, so fire off an STA
                // thread to do the actual work.
                Thread thread = new Thread(() => result = execution.ExecuteTask());
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join();
            }

            this.ExitCode = ((int)result).ToString();
            return(result == Utility.ExitCode.Success);
        }
Exemplo n.º 2
0
        public bool Execute()
        {
            // The equivalent of Main() for console access
            ExitCode result = Utility.ExitCode.GeneralFailure;

            IArgumentProvider argumentProvider = new BuildArgumentParser(this.TaskName, this.Targets, this.Options, fileService);

            using (ITaskService taskService = this.GetTaskService(ref argumentProvider))
            {
                BuildTaskExecution execution = new BuildTaskExecution(
                    buildEngine: this.BuildEngine,
                    outputHandler: this,
                    argumentProvider: argumentProvider,
                    taskRegistry: taskService.TaskRegistry);

                // We need to be on an STA thread to interact with the clipboard. We don't
                // control the main thread when executed by MSBuild, so fire off an STA
                // thread to do the actual work.
                Thread thread = new Thread(() => result = execution.ExecuteTask());
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join();
            }

            this.ExitCode = ((int)result).ToString();
            return result == Utility.ExitCode.Success;
        }