Example #1
0
 public ConsoleControl()
 {
     InitializeComponent();
     _tokenSource = new CancellationTokenSource();
     _input = new LockedQueue<string>(-1, _tokenSource.Token);
     _error = new ConsoleTextWriter(this, true);
     _output = new ConsoleTextWriter(this, false);
     _console = new ConsoleImpl(this, _input);
     _history = new List<string>();
     this.Disposed += ConsoleControl_Disposed;
     _consoleThread = new Thread(consoleThread_DoWork);
 }
Example #2
0
        private TResult Wrap <TResult>(Func <TResult> func, string actionName)
        {
            if (!ConsoleImpl.IsTraceEnabled)
            {
                return(func());
            }

            ConsoleImpl.WriteTrace("[{0}] {1}...", Name, actionName);
            var watch = Stopwatch.StartNew();

            try
            {
                var result = func();
                watch.Stop();
                ConsoleImpl.WriteTrace("[{0}] {1} took {2:0.##} second(s) and returned {3}.", Name, actionName, watch.Elapsed.TotalSeconds, result);
                return(result);
            }
            catch (Exception exception)
            {
                watch.Stop();
                ConsoleImpl.WriteTrace("[{0}] {1} took {2:0.##} second(s) and failed with {3}.", Name, actionName, watch.Elapsed.TotalSeconds, exception.Message);
                throw;
            }
        }
Example #3
0
 public void It_Should_Write_Ssis_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       ssis  [Creates a complete package with all ssis files]"));
 }
Example #4
0
 public void It_Should_Write_Eng_Utv_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       eng_utv  [Creates a complete package with english extended reports and compresses it]"));
 }
Example #5
0
 public void It_Should_Write_Eng_Std_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       eng_std  [Creates a complete package with english standard reports and compresses it]"));
 }
Example #6
0
 public void It_Should_Write_Nor_Utv_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       nor_utv  [Creates a complete package with norwegian extended reports and compresses it]"));
 }
Example #7
0
        protected override void DownloadVersionCore(string latestVersion, string target)
        {
            var apiHelper = new NugetApiHelper(PaketNugetPackageName, NugetSource);

            const string paketNupkgFile         = "paket.latest.nupkg";
            const string paketNupkgFileTemplate = "paket.{0}.nupkg";

            var paketDownloadUrl = apiHelper.GetLatestPackage();
            var paketFile        = paketNupkgFile;

            if (!String.IsNullOrWhiteSpace(latestVersion))
            {
                paketDownloadUrl = apiHelper.GetSpecificPackageVersion(latestVersion);
                paketFile        = String.Format(paketNupkgFileTemplate, latestVersion);
            }

            var randomFullPath = Path.Combine(Folder, Path.GetRandomFileName());

            FileSystemProxy.CreateDirectory(randomFullPath);
            var paketPackageFile = Path.Combine(randomFullPath, paketFile);

            if (FileSystemProxy.DirectoryExists(NugetSource))
            {
                if (String.IsNullOrWhiteSpace(latestVersion))
                {
                    latestVersion = GetLatestVersion(false);
                }
                var sourcePath = Path.Combine(NugetSource, String.Format(paketNupkgFileTemplate, latestVersion));

                ConsoleImpl.WriteInfo("Starting download from {0}", sourcePath);

                FileSystemProxy.CopyFile(sourcePath, paketPackageFile);
            }
            else
            {
                ConsoleImpl.WriteInfo("Starting download from {0}", paketDownloadUrl);

                try
                {
                    WebRequestProxy.DownloadFile(paketDownloadUrl, paketPackageFile);
                }
                catch (WebException webException)
                {
                    if (webException.Status == WebExceptionStatus.ProtocolError && !string.IsNullOrEmpty(latestVersion))
                    {
                        var response = (HttpWebResponse)webException.Response;
                        if (response.StatusCode == HttpStatusCode.NotFound)
                        {
                            throw new WebException(String.Format("Version {0} wasn't found (404)", latestVersion),
                                                   webException);
                        }
                        if (response.StatusCode == HttpStatusCode.BadRequest)
                        {
                            // For cases like "The package version is not a valid semantic version"
                            throw new WebException(String.Format("Unable to get version '{0}': {1}", latestVersion, response.StatusDescription),
                                                   webException);
                        }
                    }
                    Console.WriteLine(webException.ToString());
                    throw;
                }
            }

            FileSystemProxy.ExtractToDirectory(paketPackageFile, randomFullPath);
            var paketSourceFile = Path.Combine(randomFullPath, "tools", "paket.exe");

            FileSystemProxy.CopyFile(paketSourceFile, target, true);
            FileSystemProxy.DeleteDirectory(randomFullPath, true);
        }
Example #8
0
 public StartpointInformation(ConsoleImpl consoleImpl)
 {
     _consoleImpl = consoleImpl;
 }
Example #9
0
 public void It_Should_Write_Reports_Nor_Utv_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       reports_eng_utv  [Copies english extended and standard reports]"));
 }
Example #10
0
 public void It_Should_Write_Datasets_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       datasets  [Copies dataset files]"));
 }
Example #11
0
 public void It_Should_Write_Integration_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       integration  [Copies integration package files]"));
 }
Example #12
0
 public void It_Should_Write_Deployment_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       deployment  [copies deployment files]"));
 }
Example #13
0
 public void It_Should_Write_sql_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       sql  [Copies and merges all Reporting scripts]"));
 }
Example #14
0
 public void It_Should_Write_All_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       all  [Creates a complete package]"));
 }
Example #15
0
 public void It_Should_Write_Reporting_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       reporting  [copies all reports]"));
 }
Example #16
0
 public void It_Should_Write_Reports_Nor_Std_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       reports_nor  [Copies norwegian standard reports]"));
 }
Example #17
0
 public void It_Should_Write_Reports_Eng_Std_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       reports_eng  [Copies english standard reports]"));
 }
Example #18
0
 public void It_Should_Log()
 {
     ConsoleImpl.AssertWasCalled(x => x.Write(info));
 }
Example #19
0
 public void It_Should_Write_Nor_Std_Information()
 {
     ConsoleImpl.AssertWasCalled(x => x.Info("       nor_std  [Creates a complete package with norwegian standard reports and compresses it]"));
 }
Example #20
0
        public void SelfUpdate(string latestVersion)
        {
            string target       = Assembly.GetExecutingAssembly().Location;
            var    localVersion = FileProxy.GetLocalFileVersion(target);

            if (localVersion.StartsWith(latestVersion))
            {
                ConsoleImpl.WriteDebug("Bootstrapper is up to date. Nothing to do.");
                return;
            }
            var apiHelper = new NugetApiHelper(PaketBootstrapperNugetPackageName, NugetSource);

            const string paketNupkgFile         = "paket.bootstrapper.latest.nupkg";
            const string paketNupkgFileTemplate = "paket.bootstrapper.{0}.nupkg";
            var          getLatestFromNugetUrl  = apiHelper.GetLatestPackage();

            var paketDownloadUrl = getLatestFromNugetUrl;
            var paketFile        = paketNupkgFile;

            if (!String.IsNullOrWhiteSpace(latestVersion))
            {
                paketDownloadUrl = apiHelper.GetSpecificPackageVersion(latestVersion);
                paketFile        = String.Format(paketNupkgFileTemplate, latestVersion);
            }

            var randomFullPath = Path.Combine(Folder, Path.GetRandomFileName());

            DirectoryProxy.CreateDirectory(randomFullPath);
            var paketPackageFile = Path.Combine(randomFullPath, paketFile);

            if (DirectoryProxy.Exists(NugetSource))
            {
                if (String.IsNullOrWhiteSpace(latestVersion))
                {
                    latestVersion = GetLatestVersion(false);
                }
                var sourcePath = Path.Combine(NugetSource, String.Format(paketNupkgFileTemplate, latestVersion));

                ConsoleImpl.WriteDebug("Starting download from {0}", sourcePath);

                FileProxy.Copy(sourcePath, paketPackageFile);
            }
            else
            {
                ConsoleImpl.WriteDebug("Starting download from {0}", paketDownloadUrl);

                WebRequestProxy.DownloadFile(paketDownloadUrl, paketPackageFile);
            }

            FileProxy.ExtractToDirectory(paketPackageFile, randomFullPath);

            var paketSourceFile = Path.Combine(randomFullPath, "tools", "paket.bootstrapper.exe");
            var renamedPath     = BootstrapperHelper.GetTempFile("oldBootstrapper");

            try
            {
                FileProxy.FileMove(target, renamedPath);
                FileProxy.FileMove(paketSourceFile, target);
                ConsoleImpl.WriteDebug("Self update of bootstrapper was successful.");
            }
            catch (Exception)
            {
                ConsoleImpl.WriteDebug("Self update failed. Resetting bootstrapper.");
                FileProxy.FileMove(renamedPath, target);
                throw;
            }
            DirectoryProxy.Delete(randomFullPath, true);
        }
Example #21
0
 public FileTransferExecuter(FileExcluder fileExcluder, Copier copier, ConsoleImpl consoleImpl)
 {
     _readAndExclude = fileExcluder;
     _copier         = copier;
     _consoleImpl    = consoleImpl;
 }