MCPcopy Create free account
hub / github.com/Squirrel/Squirrel.Windows / Releasify

Method Releasify

src/Update/Program.cs:294–423  ·  view source on GitHub ↗
(string package, string targetDir = null, string packagesDir = null, string bootstrapperExe = null, string backgroundGif = null, string signingOpts = null, string baseUrl = null, string setupIcon = nu

Source from the content-addressed store, hash-verified

292 }
293
294 public void Releasify(string package, string targetDir = null, string packagesDir = null, string bootstrapperExe = null, string backgroundGif = null, string signingOpts = null, string baseUrl = null, string setupIcon = null, bool generateMsi = true, bool packageAs64Bit = false, string frameworkVersion = null, bool generateDeltas = true)
295 {
296 ensureConsole();
297
298 if (baseUrl != null) {
299 if (!Utility.IsHttpUrl(baseUrl)) {
300 throw new Exception(string.Format("Invalid --baseUrl '{0}'. A base URL must start with http or https and be a valid URI.", baseUrl));
301 }
302
303 if (!baseUrl.EndsWith("/")) {
304 baseUrl += "/";
305 }
306 }
307
308 targetDir = targetDir ?? Path.Combine(".", "Releases");
309 packagesDir = packagesDir ?? ".";
310 bootstrapperExe = bootstrapperExe ?? Path.Combine(".", "Setup.exe");
311
312 if (!Directory.Exists(targetDir)) {
313 Directory.CreateDirectory(targetDir);
314 }
315
316 if (!File.Exists(bootstrapperExe)) {
317 bootstrapperExe = Path.Combine(
318 Path.GetDirectoryName(Assembly.GetEntryAssembly().Location),
319 "Setup.exe");
320 }
321
322 this.Log().Info("Bootstrapper EXE found at:" + bootstrapperExe);
323
324 var di = new DirectoryInfo(targetDir);
325 File.Copy(package, Path.Combine(di.FullName, Path.GetFileName(package)), true);
326
327 var allNuGetFiles = di.EnumerateFiles()
328 .Where(x => x.Name.EndsWith(".nupkg", StringComparison.OrdinalIgnoreCase));
329
330 var toProcess = allNuGetFiles.Where(x => !x.Name.Contains("-delta") && !x.Name.Contains("-full"));
331 var processed = new List<string>();
332
333 var releaseFilePath = Path.Combine(di.FullName, "RELEASES");
334 var previousReleases = new List<ReleaseEntry>();
335 if (File.Exists(releaseFilePath)) {
336 previousReleases.AddRange(ReleaseEntry.ParseReleaseFile(File.ReadAllText(releaseFilePath, Encoding.UTF8)));
337 }
338
339 foreach (var file in toProcess) {
340 this.Log().Info("Creating release package: " + file.FullName);
341
342 var rp = new ReleasePackage(file.FullName);
343 rp.CreateReleasePackage(Path.Combine(di.FullName, rp.SuggestedReleaseFileName), packagesDir, contentsPostProcessHook: pkgPath => {
344 new DirectoryInfo(pkgPath).GetAllFilesRecursively()
345 .Where(x => x.Name.ToLowerInvariant().EndsWith(".exe"))
346 .Where(x => !x.Name.ToLowerInvariant().Contains("squirrel.exe"))
347 .Where(x => Utility.IsFileTopLevelInPackage(x.FullName, pkgPath))
348 .Where(x => Utility.ExecutableUsesWin32Subsystem(x.FullName))
349 .ForEachAsync(x => createExecutableStubForExe(x.FullName))
350 .Wait();
351

Callers

nothing calls this directly

Calls 15

IsHttpUrlMethod · 0.80
FormatMethod · 0.80
GetFileNameMethod · 0.80
ParseReleaseFileMethod · 0.80
ForEachAsyncMethod · 0.80
FileIsLikelyPEImageMethod · 0.80
GetPreviousReleaseMethod · 0.80
GenerateFromFileMethod · 0.80
WriteReleaseFileMethod · 0.80

Tested by

no test coverage detected