/// <summary> /// 根据文件清单生成压缩包 /// </summary> /// <param name="dev"></param> /// <param name="item"></param> /// <param name="type"></param> public static void GenerateCompressedPackage(bool dev, PublishDirInfo item, AppDownloadType type) { var fileEx = GetFileExByCompressedType(type); var packPath = GetPackPath(dev, item, fileEx); Console.WriteLine($"正在生成压缩包:{packPath}"); IOPath.FileIfExistsItDelete(packPath); GetCreatePackByCompressedType(type)(packPath, item.Files); using var fileStream = File.OpenRead(packPath); var sha256 = Hashs.String.SHA256(fileStream); var fileInfoM = new PublishFileInfo { SHA256 = sha256, Length = fileStream.Length, Path = packPath, }; if (item.BuildDownloads.ContainsKey(type)) { item.BuildDownloads[type] = fileInfoM; } else { item.BuildDownloads.Add(type, fileInfoM); } }
/// <summary> /// Gets the public link. /// </summary> /// <param name="filePath">The file path.</param> /// <param name="callback">The callback.</param> public void GetPublicLink(string filePath, Action <string> callback) { this.fileToPublish = new PublishFileInfo() { Callback = callback, FilePath = CheckPath(filePath) }; if (!fileToPublish.FilePath.StartsWith("/Public", StringComparison.InvariantCultureIgnoreCase)) { throw new Exception("You can use only files from public folder!"); } if (this.accInfo == null) { Action <AccountInfo> accUpdate = ContinueRetrievingLink; RetrieveUserInfo(accUpdate); } }
/// <summary> /// Publishes the file. /// </summary> /// <param name="content">The content.</param> /// <param name="filePath">The file path.</param> /// <param name="callback">The callback.</param> /// <returns></returns> public void PublishFile(byte[] content, string filePath, Action <string> callback) { this.fileToPublish = new PublishFileInfo() { Callback = callback, Content = content, FilePath = CheckPath(filePath) }; if (this.accInfo == null) { Action <AccountInfo> accUpdate = ContinuePublish; RetrieveUserInfo(accUpdate); } else { ContinuePublish(this.accInfo); } }
public static async System.Threading.Tasks.Task PublishAsync( TaskLoggingHelper log, string symbolServerPath, string personalAccessToken, IEnumerable <string> inputPackages, IEnumerable <string> inputFiles, HashSet <string> packageExcludeFiles, int expirationInDays, bool convertPortablePdbsToWindowsPdbs, bool publishSpecialClrFiles, HashSet <int> pdbConversionTreatAsWarning, bool treatPdbConversionIssuesAsInfo, bool dryRun, bool timer, bool verboseLogging) { var tracer = new Tracer(log, verboseLogging); PublishOperation publishOperation = new PublishOperation(tracer) { SymbolServerPath = symbolServerPath, PersonalAccessToken = personalAccessToken, PdbConversionTreatAsWarning = pdbConversionTreatAsWarning, PublishSpecialClrFiles = publishSpecialClrFiles, Timer = timer, TreatPdbConversionIssuesAsInfo = treatPdbConversionIssuesAsInfo }; using (publishOperation) { if (expirationInDays != 0) { publishOperation.ExpirationInDays = (uint)expirationInDays; } IEnumerable <PublishFileInfo> fileInfos = new PublishFileInfo[0]; if (inputFiles != null) { fileInfos = fileInfos.Concat( publishOperation.GetPublishFileInfo(inputFiles, convertPortablePdbsToWindowsPdbs)); } if (inputPackages != null) { fileInfos = fileInfos.Concat( publishOperation.GetPublishFileInfoFromPackages(inputPackages, convertPortablePdbsToWindowsPdbs)); } if (packageExcludeFiles != null) { publishOperation.PackageExcludeFiles = packageExcludeFiles; } if (dryRun) { publishOperation.StartTimer(); try { foreach (PublishFileInfo fileInfo in fileInfos) { fileInfo.Dispose(); } } catch (Exception ex) { tracer.Error("Dry Run FAILED: {0}", ex.Message); tracer.Information(ex.ToString()); } publishOperation.StopTimer(); } else { try { await publishOperation.PublishFiles(fileInfos); } catch (Exception ex) { tracer.Error("Publishing symbols failed : ", ex.Message); tracer.Information(ex.ToString()); } } } }