예제 #1
0
 public static ITascResult ExecWindowed(this TascContext context, string command, params string[] cmdParams)
 {
     return(new ExecTasc(command, cmdParams)
     {
         RunWindowed = true
     }.Execute(context));
 }
예제 #2
0
        public override ITascResult Execute(TascContext context)
        {
            ITascResult result = TascResult.Pass;

            try
            {
                var formattedParams =
                    (CommandParams != null)
                    ? string.Join(" ", CommandParams)
                    : "";

                if (RunWindowed)
                {
                    var processStartInfo = new ProcessStartInfo(Command, formattedParams)
                    {
                        CreateNoWindow = false
                    };

                    using (var process = new Process())
                    {
                        process.StartInfo                  = processStartInfo;
                        process.EnableRaisingEvents        = false;
                        process.StartInfo.WorkingDirectory = TascProject.Instance.Root;
                        process.Start();
                    }
                }
                else
                {
                    var processStartInfo = new ProcessStartInfo(Command, formattedParams)
                    {
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    };

                    using (var process = new Process())
                    {
                        process.StartInfo                  = processStartInfo;
                        process.EnableRaisingEvents        = false;
                        process.StartInfo.WorkingDirectory = TascProject.Instance.Root;
                        process.Start();

                        // Handle Standard Output
                        process.OutputDataReceived += (sender, args) => Console.WriteLine(args.Data);
                        process.ErrorDataReceived  += (sender, args) => Console.WriteLine(args.Data);
                        process.BeginOutputReadLine();
                        process.BeginErrorReadLine();

                        process.WaitForExit();
                    }
                }
            }
            catch (Exception)
            {
                result = TascResult.Fail;
            }

            return(result);
        }
예제 #3
0
 public override ITascResult Execute(TascContext context)
 {
     try
     {
         Console.WriteLine(Line);
         return(TascResult.Pass);
     }
     catch (Exception)
     {
         return(TascResult.Fail);
     }
 }
예제 #4
0
        public override ITascResult Execute(TascContext context)
        {
            Target        = Target ?? context.Properties[MSBuildOption.OutputFolder].ToString();
            Configuration = Configuration ?? context.Properties[MSBuildOption.Configuration].ToString();
            Platform      = Platform ?? context.Properties[MSBuildOption.Platform].ToString();
            OutputPath    = OutputPath ?? context.Properties[MSBuildOption.OutputFolder].ToString();

            var loggers = new List <ILogger> {
                new ConsoleLogger()
            };

            var projectFile = PathUtils.Resolve(TascProject.Instance.Root, ProjectFile);

            var globalProperty = new Dictionary <string, string>
            {
                { "Configuration", Configuration },
                { "Platform", Platform }
            };

            if (!string.IsNullOrEmpty(OutputPath))
            {
                globalProperty["OutputPath"] = PathUtils.Resolve(TascProject.Instance.Root, OutputPath);
            }

            var targets = Target.Split(',').Select(x => x.Trim());

            try
            {
                var buildRequest = new BuildRequestData(projectFile, globalProperty, null, targets.ToArray(), null);

                //register file logger using BuildParameters
                var buildParams = new BuildParameters {
                    Loggers = loggers
                };

                //build solution
                var buildResult = BuildManager.DefaultBuildManager.Build(buildParams, buildRequest);
                return(new MSBuildResult(buildResult));
            }
            catch (Exception)
            {
                return(TascResult.Fail);
            }
        }
예제 #5
0
        public static ITascResult BuildProject(this TascContext context, string projectFile, string target = null, string configuration = null, string platform = null, string outputPath = null, IDictionary <string, string> flags = null)
        {
            if (target != null)
            {
                context.Properties[MSBuildOption.Target] = target;
            }
            if (configuration != null)
            {
                context.Properties[MSBuildOption.Configuration] = configuration;
            }
            if (platform != null)
            {
                context.Properties[MSBuildOption.Platform] = platform;
            }
            if (outputPath != null)
            {
                context.Properties[MSBuildOption.OutputFolder] = outputPath;
            }

            return(new MSBuildTasc(projectFile).Execute(context));
        }
예제 #6
0
 public static ITascResult Echo(this TascContext context, string line)
 {
     return(new EchoTasc(line).Execute(context));
 }
예제 #7
0
 public override ITascResult Execute(TascContext context)
 {
     return(_action != null?_action(context) : TascResult.Pass);
 }