protected override void DownloadVersionCore(string latestVersion, string target, PaketHashFile hashfile) { string url = String.Format(Constants.PaketNupkgDownloadUrlTemplate, latestVersion); ConsoleImpl.WriteInfo("Starting download from {0}", url); var tmpFile = BootstrapperHelper.GetTempFile("paketnupkg"); WebRequestProxy.DownloadFile(url, tmpFile); string packageName = Path.GetFileName(url); var randomFullPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); FileSystemProxy.CreateDirectory(randomFullPath); string packagePath = Path.Combine(randomFullPath, packageName); FileSystemProxy.CopyFile(tmpFile, packagePath, true); FileSystemProxy.DeleteFile(tmpFile); var installAsTool = new InstallKind.InstallAsTool(FileSystemProxy); installAsTool.Run(randomFullPath, target, latestVersion); FileSystemProxy.DeleteDirectory(randomFullPath, true); }
protected override void DownloadVersionCore(string latestVersion, string target, PaketHashFile hashfile) { var url = String.Format(Constants.PaketExeDownloadUrlTemplate, latestVersion); ConsoleImpl.WriteInfo("Starting download from {0}", url); var tmpFile = BootstrapperHelper.GetTempFile("paket"); WebRequestProxy.DownloadFile(url, tmpFile); if (!BootstrapperHelper.ValidateHash(FileSystemProxy, hashfile, latestVersion, tmpFile)) { ConsoleImpl.WriteWarning("Hash of downloaded paket.exe is invalid, retrying once"); WebRequestProxy.DownloadFile(url, tmpFile); if (!BootstrapperHelper.ValidateHash(FileSystemProxy, hashfile, latestVersion, tmpFile)) { ConsoleImpl.WriteWarning("Hash of downloaded paket.exe still invalid (Using the file anyway)"); } else { ConsoleImpl.WriteTrace("Hash of downloaded file successfully found in {0}", hashfile); } } else { ConsoleImpl.WriteTrace("Hash of downloaded file successfully found in {0}", hashfile); } FileSystemProxy.CopyFile(tmpFile, target, true); FileSystemProxy.DeleteFile(tmpFile); }
public void DeleteFile_File() { var testFileSource = CreateTestFile(SourceData, TestFileName: GetTestFileName()); Assert.True(System.IO.File.Exists(testFileSource)); _fileSystem.DeleteFile(testFileSource); Assert.False(System.IO.File.Exists(testFileSource)); }
public void DownloadVersion(string latestVersion, string target) { var url = String.Format(Constants.PaketExeDownloadUrlTemplate, latestVersion); ConsoleImpl.WriteDebug("Starting download from {0}", url); var tmpFile = BootstrapperHelper.GetTempFile("paket"); WebRequestProxy.DownloadFile(url, tmpFile); FileSystemProxy.CopyFile(tmpFile, target, true); FileSystemProxy.DeleteFile(tmpFile); }
public void DeleteFileTest() { var p = new FileSystemProxy(); var s = p.CreateTempEmptyFolder(); var fname = p + "1.txt"; using (var f = File.CreateText(fname)) { } var b = File.Exists(fname); Assert.IsTrue(b); p.DeleteFile(fname); b = File.Exists(fname); Assert.IsFalse(b); Directory.Delete(s, true); }