Example #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);
        }
Example #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;
        }
 public void BasicTaskTest()
 {
     BuildArgumentParser parser = new BuildArgumentParser("task", null, null);
     parser.Command.Should().Be("task");
 }
 public void MultiOptionTest()
 {
     string options = @"<Foo>Bar</Foo><Foo>Foo</Foo>";
     BuildArgumentParser parser = new BuildArgumentParser("task", null, options);
     parser.GetOption<string>("foo").Should().Be("Bar;Foo");
 }
 public void BasicTargetsTest()
 {
     BuildArgumentParser parser = new BuildArgumentParser("task", new string[] { "foo", "bar" }, null);
     parser.Target.Should().Be("foo");
     parser.Targets.Should().ContainInOrder("foo", "bar");
 }