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); }
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; } }
public void It_Should_Write_Ssis_Information() { ConsoleImpl.AssertWasCalled(x => x.Info(" ssis [Creates a complete package with all ssis files]")); }
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]")); }
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]")); }
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]")); }
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); }
public StartpointInformation(ConsoleImpl consoleImpl) { _consoleImpl = consoleImpl; }
public void It_Should_Write_Reports_Nor_Utv_Information() { ConsoleImpl.AssertWasCalled(x => x.Info(" reports_eng_utv [Copies english extended and standard reports]")); }
public void It_Should_Write_Datasets_Information() { ConsoleImpl.AssertWasCalled(x => x.Info(" datasets [Copies dataset files]")); }
public void It_Should_Write_Integration_Information() { ConsoleImpl.AssertWasCalled(x => x.Info(" integration [Copies integration package files]")); }
public void It_Should_Write_Deployment_Information() { ConsoleImpl.AssertWasCalled(x => x.Info(" deployment [copies deployment files]")); }
public void It_Should_Write_sql_Information() { ConsoleImpl.AssertWasCalled(x => x.Info(" sql [Copies and merges all Reporting scripts]")); }
public void It_Should_Write_All_Information() { ConsoleImpl.AssertWasCalled(x => x.Info(" all [Creates a complete package]")); }
public void It_Should_Write_Reporting_Information() { ConsoleImpl.AssertWasCalled(x => x.Info(" reporting [copies all reports]")); }
public void It_Should_Write_Reports_Nor_Std_Information() { ConsoleImpl.AssertWasCalled(x => x.Info(" reports_nor [Copies norwegian standard reports]")); }
public void It_Should_Write_Reports_Eng_Std_Information() { ConsoleImpl.AssertWasCalled(x => x.Info(" reports_eng [Copies english standard reports]")); }
public void It_Should_Log() { ConsoleImpl.AssertWasCalled(x => x.Write(info)); }
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]")); }
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); }
public FileTransferExecuter(FileExcluder fileExcluder, Copier copier, ConsoleImpl consoleImpl) { _readAndExclude = fileExcluder; _copier = copier; _consoleImpl = consoleImpl; }