public void Validate()
        {
            var startInfo = CommandLineProgram.Prepare()
                            .WithFileName(@"sqlcmd.exe")
                            .WithArguments(new [] { "-?" });

            try
            {
                CommandLineProgram.Run(startInfo);
            }
            catch (System.ComponentModel.Win32Exception)
            {
                throw new SqlCmdNotFoundException("SQLCMD is not found in your system");
            }
        }
        public void Execute(string scriptFileName)
        {
            var args = GetArgs(scriptFileName);

            var startInfo = CommandLineProgram.Prepare()
                            .WithFileName(@"sqlcmd.exe")
                            .WithArguments(args);

            this.logger.Log("Executing file: {0}", scriptFileName);

            var result = CommandLineProgram.Run(startInfo);

            LogIfHasSomething(result.Error);
            LogIfHasSomething(result.Output);

            if (result.ExitCode != 0)
            {
                throw new InvalidOperationException(
                          string.Format(
                              "Executing {0} finished with the exit code: {1}. Please check log file for more details.",
                              scriptFileName, result.ExitCode));
            }
        }
Ejemplo n.º 3
0
 public static new void Main <TProgram>(string[] args) where TProgram : CommandLineProgram => CommandLineProgram.Main <TProgram>(args);