mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Minor changes to spelling, comments, code style
This commit is contained in:
@@ -135,13 +135,13 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
|
||||
|
||||
protected override Task CreateSetupPackage(Action<int> progress, string releasePkg, string packDir, string targetSetupExe)
|
||||
{
|
||||
var bundledzp = new ZipPackage(releasePkg);
|
||||
var bundledZip = new ZipPackage(releasePkg);
|
||||
Utility.Retry(() => File.Copy(HelperFile.SetupPath, targetSetupExe, true));
|
||||
progress(10);
|
||||
if (VelopackRuntimeInfo.IsWindows) {
|
||||
Rcedit.SetPEVersionBlockFromPackageInfo(targetSetupExe, bundledzp, Options.Icon);
|
||||
Rcedit.SetPEVersionBlockFromPackageInfo(targetSetupExe, bundledZip, Options.Icon);
|
||||
} else {
|
||||
Log.Warn("Unable to set Setup.exe icon (only supported on windows)");
|
||||
Log.Warn("Unable to set PE Version on Setup.exe (only supported on windows)");
|
||||
}
|
||||
progress(25);
|
||||
Log.Debug($"Creating Setup bundle");
|
||||
|
||||
@@ -21,16 +21,16 @@ public static class SetupBundle
|
||||
|
||||
void FindBundleHeader()
|
||||
{
|
||||
using (var memoryMappedFile = MemoryMappedFile.CreateFromFile(setupPath, FileMode.Open, null, 0, MemoryMappedFileAccess.Read))
|
||||
using (MemoryMappedViewAccessor accessor = memoryMappedFile.CreateViewAccessor(0, 0, MemoryMappedFileAccess.Read)) {
|
||||
int position = BinaryUtils.SearchInFile(accessor, bundleSignature);
|
||||
if (position == -1) {
|
||||
throw new PlaceHolderNotFoundInAppHostException(bundleSignature);
|
||||
}
|
||||
using var memoryMappedFile = MemoryMappedFile.CreateFromFile(setupPath, FileMode.Open, null, 0, MemoryMappedFileAccess.Read);
|
||||
using MemoryMappedViewAccessor accessor = memoryMappedFile.CreateViewAccessor(0, 0, MemoryMappedFileAccess.Read);
|
||||
|
||||
offset = accessor.ReadInt64(position - 16);
|
||||
length = accessor.ReadInt64(position - 8);
|
||||
int position = BinaryUtils.SearchInFile(accessor, bundleSignature);
|
||||
if (position == -1) {
|
||||
throw new PlaceHolderNotFoundInAppHostException(bundleSignature);
|
||||
}
|
||||
|
||||
offset = accessor.ReadInt64(position - 16);
|
||||
length = accessor.ReadInt64(position - 8);
|
||||
}
|
||||
|
||||
Utility.Retry(FindBundleHeader);
|
||||
@@ -53,8 +53,8 @@ public static class SetupBundle
|
||||
bundleLength = pkgStream.Length;
|
||||
pkgStream.CopyTo(setupStream);
|
||||
} finally {
|
||||
if (pkgStream != null) pkgStream.Dispose();
|
||||
if (setupStream != null) setupStream.Dispose();
|
||||
pkgStream?.Dispose();
|
||||
setupStream?.Dispose();
|
||||
}
|
||||
|
||||
byte[] placeholder = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Velopack.Packaging.Abstractions;
|
||||
namespace Velopack.Packaging.Abstractions;
|
||||
|
||||
public interface ICommand<TOpt> where TOpt : class
|
||||
{
|
||||
|
||||
5
src/Velopack.Packaging/Abstractions/IConsole.cs
Normal file
5
src/Velopack.Packaging/Abstractions/IConsole.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Velopack.Packaging.Abstractions;
|
||||
public interface IConsole
|
||||
{
|
||||
void WriteLine(string message = "");
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
namespace Velopack.Packaging.Abstractions;
|
||||
|
||||
public interface IFancyConsole
|
||||
public interface IFancyConsole : IConsole
|
||||
{
|
||||
Task ExecuteProgressAsync(Func<IFancyConsoleProgress, Task> action);
|
||||
|
||||
void WriteTable(string tableName, IEnumerable<IEnumerable<string>> rows, bool hasHeaderRow = true);
|
||||
|
||||
Task<bool> PromptYesNo(string prompt, bool? defaultValue = null, TimeSpan? timeout = null);
|
||||
|
||||
void WriteLine(string text = "");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Velopack.Packaging.Abstractions;
|
||||
namespace Velopack.Packaging.Abstractions;
|
||||
|
||||
public interface IPlatformOptions : IOutputOptions
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using NuGet.Versioning;
|
||||
|
||||
#if NET5_0_OR_GREATER
|
||||
|
||||
@@ -486,8 +486,7 @@ namespace Velopack
|
||||
|
||||
public static bool IsHttpUrl(string urlOrPath)
|
||||
{
|
||||
var uri = default(Uri);
|
||||
if (!Uri.TryCreate(urlOrPath, UriKind.Absolute, out uri)) {
|
||||
if (!Uri.TryCreate(urlOrPath, UriKind.Absolute, out Uri? uri)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -64,7 +64,7 @@ namespace Velopack.Sources
|
||||
public virtual async Task<VelopackAssetFeed> GetReleaseFeed(ILogger logger, string channel, Guid? stagingId = null, VelopackAsset? latestLocalRelease = null)
|
||||
{
|
||||
var releases = await GetReleases(Prerelease).ConfigureAwait(false);
|
||||
if (releases == null || releases.Count() == 0) {
|
||||
if (releases == null || releases.Length == 0) {
|
||||
logger.Warn($"No releases found at '{RepoUri}'.");
|
||||
return new VelopackAssetFeed();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Velopack.Sources
|
||||
[JsonPropertyName("prerelease")]
|
||||
public bool Prerelease { get; set; }
|
||||
|
||||
/// <summary> The date which this release was published publically. </summary>
|
||||
/// <summary> The date which this release was published publicly. </summary>
|
||||
[JsonPropertyName("published_at")]
|
||||
public DateTime? PublishedAt { get; set; }
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Velopack.Sources
|
||||
public bool UpcomingRelease { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The date which this release was published publically.
|
||||
/// The date which this release was published publicly.
|
||||
/// </summary>
|
||||
[JsonPropertyName("released_at")]
|
||||
public DateTime? ReleasedAt { get; set; }
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Velopack.Sources
|
||||
/// <param name="url">The url which will be downloaded.</param>
|
||||
/// <param name="targetFile">
|
||||
/// The local path where the file will be stored
|
||||
/// If a file exists at this path, it will be overritten.</param>
|
||||
/// If a file exists at this path, it will be overwritten.</param>
|
||||
/// <param name="progress">
|
||||
/// A delegate for reporting download progress, with expected values from 0-100.
|
||||
/// </param>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Velopack
|
||||
VelopackDisplayVersion = VelopackNugetVersion.ToNormalizedString() + (VelopackNugetVersion.IsPrerelease ? " (prerelease)" : "");
|
||||
#pragma warning restore CS0612
|
||||
|
||||
// get real cpu architecture, even when virtualised by Wow64
|
||||
// get real cpu architecture, even when virtualized by Wow64
|
||||
#if NETFRAMEWORK
|
||||
CheckArchitectureWindows();
|
||||
#else
|
||||
@@ -216,7 +216,7 @@ namespace Velopack
|
||||
SystemOs = RuntimeOs.Windows;
|
||||
|
||||
// find the actual OS architecture. We can't rely on the framework alone for this on Windows
|
||||
// because Wow64 virtualisation is good enough to trick us to believing we're running natively
|
||||
// because Wow64 virtualization is good enough to trick us to believing we're running natively
|
||||
// in some cases unless we use functions that are not virtualized (such as IsWow64Process2)
|
||||
|
||||
try {
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.2" />
|
||||
<PackageReference Include="Xunit.Abstractions" Version="2.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -346,7 +346,7 @@ public class WindowsPackTests
|
||||
new DeltaPatchCommandRunner(logger, new BasicConsole(logger, new DefaultPromptValueFactory(false))).Run(new DeltaPatchOptions {
|
||||
BasePackage = Path.Combine(releaseDir, $"{id}-1.0.0-full.nupkg"),
|
||||
OutputFile = output,
|
||||
PatchFiles = new[] { new FileInfo(deltaPath), new FileInfo(deltav3) },
|
||||
PatchFiles = [new FileInfo(deltaPath), new FileInfo(deltav3)],
|
||||
}).GetAwaiterResult();
|
||||
|
||||
// are the packages the same?
|
||||
@@ -373,7 +373,7 @@ public class WindowsPackTests
|
||||
|
||||
// install app
|
||||
var setupPath1 = Path.Combine(releaseDir, $"{id}-win-Setup.exe");
|
||||
RunNoCoverage(setupPath1, new string[] { "--nocolor", "--installto", installDir },
|
||||
RunNoCoverage(setupPath1, ["--nocolor", "--installto", installDir],
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.Desktop), logger);
|
||||
|
||||
var argsPath = Path.Combine(installDir, "args.txt");
|
||||
@@ -388,8 +388,8 @@ public class WindowsPackTests
|
||||
PackTestApp(id, "2.0.0", "version 2 test", releaseDir, logger);
|
||||
|
||||
// install v2
|
||||
RunCoveredDotnet(appPath, new string[] { "download", releaseDir }, installDir, logger);
|
||||
RunCoveredDotnet(appPath, new string[] { "apply", releaseDir }, installDir, logger, exitCode: null);
|
||||
RunCoveredDotnet(appPath, ["download", releaseDir], installDir, logger);
|
||||
RunCoveredDotnet(appPath, ["apply", releaseDir], installDir, logger, exitCode: null);
|
||||
|
||||
Thread.Sleep(2000);
|
||||
|
||||
@@ -404,7 +404,7 @@ public class WindowsPackTests
|
||||
Assert.Equal("2.0.0,test,args !!", File.ReadAllText(restartedPath).Trim());
|
||||
|
||||
var updatePath = Path.Combine(installDir, "Update.exe");
|
||||
RunNoCoverage(updatePath, new string[] { "--nocolor", "--silent", "--uninstall" }, Environment.CurrentDirectory, logger);
|
||||
RunNoCoverage(updatePath, ["--nocolor", "--silent", "--uninstall"], Environment.CurrentDirectory, logger);
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
@@ -550,7 +550,7 @@ public class WindowsPackTests
|
||||
|
||||
//private string RunCoveredRust(string binName, string[] args, string workingDir, ILogger logger, int? exitCode = 0)
|
||||
//{
|
||||
// var outputfile = GetPath($"coverage.runrust.{RandomString(8)}.xml");
|
||||
// var outputFile = GetPath($"coverage.runrust.{RandomString(8)}.xml");
|
||||
// var manifestFile = GetPath("..", "src", "Rust", "Cargo.toml");
|
||||
|
||||
// var psi = new ProcessStartInfo("cargo");
|
||||
@@ -565,7 +565,7 @@ public class WindowsPackTests
|
||||
// psi.ArgumentList.Add("--manifest-path");
|
||||
// psi.ArgumentList.Add(manifestFile);
|
||||
// psi.ArgumentList.Add("--output");
|
||||
// psi.ArgumentList.Add(outputfile);
|
||||
// psi.ArgumentList.Add(outputFile);
|
||||
// psi.ArgumentList.Add("--bin");
|
||||
// psi.ArgumentList.Add(binName);
|
||||
// psi.ArgumentList.Add("--");
|
||||
@@ -579,7 +579,7 @@ public class WindowsPackTests
|
||||
//logger.Info($"TEST: Running {psi.FileName} {psi.ArgumentList.Aggregate((a, b) => $"{a} {b}")}");
|
||||
//using var p = Process.Start(psi);
|
||||
|
||||
var outputfile = PathHelper.GetTestRootPath($"run.{RandomString(8)}.log");
|
||||
var outputFile = PathHelper.GetTestRootPath($"run.{RandomString(8)}.log");
|
||||
|
||||
try {
|
||||
// this is a huge hack, but WaitForProcess hangs in the test runner when the output is redirected
|
||||
@@ -591,7 +591,7 @@ public class WindowsPackTests
|
||||
var fix = new ProcessStartInfo("cmd.exe");
|
||||
fix.CreateNoWindow = true;
|
||||
fix.WorkingDirectory = psi.WorkingDirectory;
|
||||
fix.Arguments = $"/c \"{psi.FileName}\" {debug} > {outputfile} 2>&1";
|
||||
fix.Arguments = $"/c \"{psi.FileName}\" {debug} > {outputFile} 2>&1";
|
||||
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
@@ -609,7 +609,7 @@ public class WindowsPackTests
|
||||
logger.Info($"TEST: Process exited with code {p.ExitCode} in {elapsed.TotalSeconds}s");
|
||||
|
||||
using var fs = Utility.Retry(() => {
|
||||
return File.Open(outputfile, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
|
||||
return File.Open(outputFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
|
||||
}, 10, 1000, logger);
|
||||
|
||||
using var reader = new StreamReader(fs);
|
||||
@@ -633,7 +633,7 @@ public class WindowsPackTests
|
||||
).Trim();
|
||||
} finally {
|
||||
try {
|
||||
File.Delete(outputfile);
|
||||
File.Delete(outputFile);
|
||||
} catch { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Choose>
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.IO.Packaging" Version="8.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" $(TargetFramework.StartsWith('net4')) ">
|
||||
|
||||
Reference in New Issue
Block a user