示例#1
0
        private void TryGetTargetsFromArguments(OptionsAndArguments optionsAndArguments)
        {
            var args = optionsAndArguments.RemainingArguments;

            if (args.Length > 0)
            {
                var firstArg = args[0];
                _bounceDir = "bounceDir";
                if (firstArg.StartsWith("/" + _bounceDir + ":"))
                {
                    var remainingArgs = new string[args.Length - 1];
                    Array.Copy(args, 1, remainingArgs, 0, remainingArgs.Length);
                    optionsAndArguments.BounceDirectory    = firstArg.Substring(("/" + _bounceDir + ":").Length);
                    optionsAndArguments.RemainingArguments = remainingArgs;
                    optionsAndArguments.WorkingDirectory   = Directory.GetCurrentDirectory();
                }
                else if (firstArg == "/" + _bounceDir)
                {
                    var remainingArgs = new string[args.Length - 2];
                    Array.Copy(args, 2, remainingArgs, 0, remainingArgs.Length);
                    optionsAndArguments.BounceDirectory    = args[1];
                    optionsAndArguments.RemainingArguments = remainingArgs;
                    optionsAndArguments.WorkingDirectory   = Directory.GetCurrentDirectory();
                }
            }
        }
示例#2
0
        public void RunBeforeBounceScript(OptionsAndArguments optionsAndArguments)
        {
            if (optionsAndArguments.TargetsAssembly.ExecutableType == BounceDirectoryExecutableType.BeforeBounce) {
                LogRunningBeforeBounceScript(optionsAndArguments.TargetsAssembly.Executable);

                var processInfo = new ProcessStartInfo(optionsAndArguments.TargetsAssembly.Executable);
                processInfo.CreateNoWindow = true;
                processInfo.RedirectStandardError = true;
                processInfo.RedirectStandardOutput = true;
                processInfo.UseShellExecute = false;

                var p = new Process { StartInfo = processInfo };
                var capturer = new RedirectedProcessOutputCapturer();
                p.Start();
                capturer.CaptureOutputForProcess(p);
                p.WaitForExit();

                if (p.ExitCode != 0) {
                    throw new BeforeBounceScriptException(optionsAndArguments.TargetsAssembly.Executable,
                                                          capturer.CapturedOutput, p.ExitCode);
                }

                optionsAndArguments.TargetsAssembly.Executable = @"Bounce\Targets.dll";
                optionsAndArguments.TargetsAssembly.ExecutableType = BounceDirectoryExecutableType.Targets;
            }
        }
 private void TryGetTargetsFromArguments(OptionsAndArguments optionsAndArguments)
 {
     var args = optionsAndArguments.RemainingArguments;
     if (args.Length > 0)
     {
         var firstArg = args[0];
         if (firstArg.StartsWith("/targets:"))
         {
             var remainingArgs = new string[args.Length - 1];
             Array.Copy(args, 1, remainingArgs, 0, remainingArgs.Length);
             optionsAndArguments.TargetsAssembly = new BounceDirectoryExecutable {
                 Executable = firstArg.Substring("/targets:".Length),
                 ExecutableType = BounceDirectoryExecutableType.Targets
             };
             optionsAndArguments.RemainingArguments = remainingArgs;
         }
         else if (firstArg == "/targets")
         {
             var remainingArgs = new string[args.Length - 2];
             Array.Copy(args, 2, remainingArgs, 0, remainingArgs.Length);
             optionsAndArguments.TargetsAssembly = new BounceDirectoryExecutable {
                 Executable = args[1],
                 ExecutableType = BounceDirectoryExecutableType.Targets
             };
             optionsAndArguments.RemainingArguments = remainingArgs;
         }
     }
 }
示例#4
0
        public OptionsAndArguments GetTargetsAssembly(string[] args)
        {
            var optionsAndArguments = new OptionsAndArguments {
                RemainingArguments = args
            };

            TryGetTargetsFromArguments(optionsAndArguments);

            TryGetRecurseFromArguments(optionsAndArguments);

            if (optionsAndArguments.BounceDirectory != null)
            {
                return(optionsAndArguments);
            }

            var targets = _bounceDirectoryFinder.FindBounceDirectory();

            if (targets != null)
            {
                optionsAndArguments.BounceDirectory  = targets;
                optionsAndArguments.WorkingDirectory = Path.GetDirectoryName(Path.GetFullPath(targets));
                return(optionsAndArguments);
            }
            else
            {
                throw new TargetsAssemblyNotFoundException();
            }
        }
示例#5
0
        public void RunBeforeBounceScript(OptionsAndArguments optionsAndArguments)
        {
            string script = BeforeBounceScript(optionsAndArguments.BounceDirectory);

            if (script != null)
            {
                LogRunningBeforeBounceScript(script);

                var processInfo = new ProcessStartInfo(script);
                processInfo.CreateNoWindow         = true;
                processInfo.RedirectStandardError  = true;
                processInfo.RedirectStandardOutput = true;
                processInfo.UseShellExecute        = false;

                var p = new Process {
                    StartInfo = processInfo
                };
                var capturer = new RedirectedProcessOutputCapturer();
                p.Start();
                capturer.CaptureOutputForProcess(p);
                p.WaitForExit();

                if (p.ExitCode != 0)
                {
                    throw new BeforeBounceScriptException(script, capturer.CapturedOutput, p.ExitCode);
                }
            }
        }
 private void TryGetTargetsFromArguments(OptionsAndArguments optionsAndArguments)
 {
     var args = optionsAndArguments.RemainingArguments;
     if (args.Length > 0)
     {
         var firstArg = args[0];
         _bounceDir = "bounceDir";
         if (firstArg.StartsWith("/" + _bounceDir + ":"))
         {
             var remainingArgs = new string[args.Length - 1];
             Array.Copy(args, 1, remainingArgs, 0, remainingArgs.Length);
             optionsAndArguments.BounceDirectory = firstArg.Substring(("/" + _bounceDir + ":").Length);
             optionsAndArguments.RemainingArguments = remainingArgs;
             optionsAndArguments.WorkingDirectory = Directory.GetCurrentDirectory();
         }
         else if (firstArg == "/" + _bounceDir)
         {
             var remainingArgs = new string[args.Length - 2];
             Array.Copy(args, 2, remainingArgs, 0, remainingArgs.Length);
             optionsAndArguments.BounceDirectory = args[1];
             optionsAndArguments.RemainingArguments = remainingArgs;
             optionsAndArguments.WorkingDirectory = Directory.GetCurrentDirectory();
         }
     }
 }
 private void TryGetRecurseFromArguments(OptionsAndArguments optionsAndArguments)
 {
     var args = optionsAndArguments.RemainingArguments;
     if (args.Length > 0)
     {
         var firstArg = args[0];
         if (firstArg == "/recurse")
         {
             var remainingArgs = new string[args.Length - 1];
             Array.Copy(args, 1, remainingArgs, 0, remainingArgs.Length);
             optionsAndArguments.Recurse = true;
             optionsAndArguments.RemainingArguments = remainingArgs;
         }
     }
 }
示例#8
0
        private void TryGetRecurseFromArguments(OptionsAndArguments optionsAndArguments)
        {
            var args = optionsAndArguments.RemainingArguments;

            if (args.Length > 0)
            {
                var firstArg = args[0];
                if (firstArg == "/recurse")
                {
                    var remainingArgs = new string[args.Length - 1];
                    Array.Copy(args, 1, remainingArgs, 0, remainingArgs.Length);
                    optionsAndArguments.Recurse            = true;
                    optionsAndArguments.RemainingArguments = remainingArgs;
                }
            }
        }
示例#9
0
        public string CopyBounceDirectory(OptionsAndArguments optionsAndArguments)
        {
            var bounceDirectory = Path.GetDirectoryName(optionsAndArguments.TargetsAssembly);
            var tempBounceDir = Path.Combine(Path.GetDirectoryName(bounceDirectory), bounceDirectory + ".tmp");

            if (!optionsAndArguments.Recurse)
            {
                if (Directory.Exists(tempBounceDir))
                {
                    Directory.Delete(tempBounceDir, true);
                }

                Directory.CreateDirectory(tempBounceDir);

                CopyDirectory(bounceDirectory, tempBounceDir);
            }

            return Path.Combine(tempBounceDir, Path.GetFileName(optionsAndArguments.TargetsAssembly));
        }
        public OptionsAndArguments GetTargetsAssembly(string[] args)
        {
            OptionsAndArguments optionsAndArguments = new OptionsAndArguments {RemainingArguments = args};

            TryGetTargetsFromArguments(optionsAndArguments);
            TryGetRecurseFromArguments(optionsAndArguments);

            if (optionsAndArguments.TargetsAssembly != null)
            {
                return optionsAndArguments;
            }

            var targets = TargetsAssemblyFinder.FindTargetsAssembly();
            if (targets != null) {
                optionsAndArguments.TargetsAssembly = targets;
                return optionsAndArguments;
            } else {
                throw new TargetsAssemblyNotFoundException();
            }
        }
        public OptionsAndArguments GetTargetsAssembly(string[] args)
        {
            var optionsAndArguments = new OptionsAndArguments {RemainingArguments = args};

            TryGetTargetsFromArguments(optionsAndArguments);

            TryGetRecurseFromArguments(optionsAndArguments);

            if (optionsAndArguments.BounceDirectory != null)
            {
                return optionsAndArguments;
            }

            var targets = _bounceDirectoryFinder.FindBounceDirectory();
            if (targets != null) {
                optionsAndArguments.BounceDirectory = targets;
                optionsAndArguments.WorkingDirectory = Path.GetDirectoryName(Path.GetFullPath(targets));
                return optionsAndArguments;
            } else {
                throw new TargetsAssemblyNotFoundException();
            }
        }