diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ade677a..7538652a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -135,13 +135,13 @@ jobs: key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} restore-keys: ${{ runner.os }}-nuget- - - name: Download Rust Windows + - name: Download Rust OSX uses: actions/download-artifact@v4 with: name: rust-macos-latest path: src/Rust/target/release - - name: Download Rust OSX + - name: Download Rust Windows uses: actions/download-artifact@v4 with: name: rust-windows-latest diff --git a/Velopack.sln b/Velopack.sln index ce8edfa3..a8008356 100644 --- a/Velopack.sln +++ b/Velopack.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31815.197 @@ -12,7 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionLevel", "SolutionLe .editorconfig = .editorconfig .github\workflows\build.yml = .github\workflows\build.yml src\Directory.Build.props = src\Directory.Build.props - test\Directory.Build.props = test\Directory.Build.props nuget.config = nuget.config README.md = README.md Velopack.entitlements = Velopack.entitlements @@ -26,6 +25,9 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Velopack.CommandLine.Tests", "test\Velopack.CommandLine.Tests\Velopack.CommandLine.Tests.csproj", "{519EAB50-47B8-425F-8B20-AB9548F220B4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{7AC3A776-B582-4B65-9D03-BD52332B5CA3}" + ProjectSection(SolutionItems) = preProject + test\Directory.Build.props = test\Directory.Build.props + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Velopack.Packaging.Windows", "src\Velopack.Packaging.Windows\Velopack.Packaging.Windows.csproj", "{E35039C8-1F98-48EB-B7D5-08E33DF061A7}" EndProject diff --git a/examples/AvaloniaCrossPlat/dev-scripts/build-win.bat b/examples/AvaloniaCrossPlat/dev-scripts/build-win.bat index c62035fc..f090aa7d 100644 --- a/examples/AvaloniaCrossPlat/dev-scripts/build-win.bat +++ b/examples/AvaloniaCrossPlat/dev-scripts/build-win.bat @@ -1,4 +1,9 @@ @echo off +REM This script requires several tools to be installed for it to work: +REM cargo (rust): winget install Rustlang.Rustup +REM Nerdbank.GitVersioning (nbgv): dotnet tool install --global nbgv +REM C++ Build Tools, typically installed via "Desktop development with C++" workload. + setlocal enabledelayedexpansion if "%~1"=="" ( diff --git a/src/Velopack.Deployment/_Repository.cs b/src/Velopack.Deployment/_Repository.cs index 2864c89e..6cff4326 100644 --- a/src/Velopack.Deployment/_Repository.cs +++ b/src/Velopack.Deployment/_Repository.cs @@ -64,7 +64,7 @@ public abstract class DownRepository : IRepositoryCanDownload var latest = releases.Where(r => r.Type == VelopackAssetType.Full).OrderByDescending(r => r.Version).FirstOrDefault(); if (latest == null) { - Log.Warn("No full / applicible release was found to download. Aborting."); + Log.Warn("No full / applicable release was found to download. Aborting."); return; } diff --git a/src/Velopack.Packaging.Unix/Velopack.Packaging.Unix.csproj b/src/Velopack.Packaging.Unix/Velopack.Packaging.Unix.csproj index f258687a..d14d4aba 100644 --- a/src/Velopack.Packaging.Unix/Velopack.Packaging.Unix.csproj +++ b/src/Velopack.Packaging.Unix/Velopack.Packaging.Unix.csproj @@ -1,7 +1,7 @@  - net6.0 + net6.0;netstandard2.0 enable $(NoWarn);CA2007;CS8002 diff --git a/src/Velopack.Packaging.Windows/Commands/WindowsPackCommandRunner.cs b/src/Velopack.Packaging.Windows/Commands/WindowsPackCommandRunner.cs index 8605f2b1..155c0df1 100644 --- a/src/Velopack.Packaging.Windows/Commands/WindowsPackCommandRunner.cs +++ b/src/Velopack.Packaging.Windows/Commands/WindowsPackCommandRunner.cs @@ -204,7 +204,7 @@ public class WindowsPackCommandRunner : PackageBuilder var helper = new CodeSign(Log); if (string.IsNullOrEmpty(signParams) && string.IsNullOrEmpty(signTemplate)) { - Log.Warn($"No signing paramaters provided, {filePaths.Length} file(s) will not be signed."); + Log.Warn($"No signing parameters provided, {filePaths.Length} file(s) will not be signed."); return; } diff --git a/src/Velopack.Packaging.Windows/HostModel/Bundle/Bundler.cs b/src/Velopack.Packaging.Windows/HostModel/Bundle/Bundler.cs index b43987ef..5a10e427 100644 --- a/src/Velopack.Packaging.Windows/HostModel/Bundle/Bundler.cs +++ b/src/Velopack.Packaging.Windows/HostModel/Bundle/Bundler.cs @@ -1,12 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.IO; using System.IO.Compression; -using System.Linq; using System.Reflection.PortableExecutable; using System.Runtime.InteropServices; using Microsoft.NET.HostModel.AppHost; diff --git a/src/Velopack.Packaging.Windows/Velopack.Packaging.Windows.csproj b/src/Velopack.Packaging.Windows/Velopack.Packaging.Windows.csproj index 009b10e0..90652f85 100644 --- a/src/Velopack.Packaging.Windows/Velopack.Packaging.Windows.csproj +++ b/src/Velopack.Packaging.Windows/Velopack.Packaging.Windows.csproj @@ -1,7 +1,7 @@  - net6.0 + net6.0;netstandard2.0 enable true $(NoWarn);CA2007;CS8002 @@ -14,6 +14,7 @@ + diff --git a/src/Velopack.Packaging/BuildAssets.cs b/src/Velopack.Packaging/BuildAssets.cs index 74fbbb24..59ba5b4e 100644 --- a/src/Velopack.Packaging/BuildAssets.cs +++ b/src/Velopack.Packaging/BuildAssets.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; -using Velopack.Json; +using Velopack.Json; using Velopack.Packaging.Exceptions; namespace Velopack.Packaging @@ -26,7 +20,7 @@ namespace Velopack.Packaging Files = files.OrderBy(f => f).ToList(), }; var path = Path.Combine(outputDir, $"assets.{channel}.json"); - var json = JsonSerializer.Serialize(assets, SimpleJson.Options); + var json = SimpleJson.SerializeObject(assets); File.WriteAllText(path, json); } @@ -37,7 +31,7 @@ namespace Velopack.Packaging throw new UserInfoException($"Could not find assets file for channel '{channel}' (looking for '{Path.GetFileName(path)}' in directory '{outputDir}'). " + $"If you've just created a Velopack release, verify you're calling this command with the same '--channel' as you did with 'pack'."); } - return JsonSerializer.Deserialize(File.ReadAllText(path), SimpleJson.Options); + return SimpleJson.DeserializeObject(File.ReadAllText(path)); } } } diff --git a/src/Velopack.Packaging/DeltaPackageBuilder.cs b/src/Velopack.Packaging/DeltaPackageBuilder.cs index 132921f3..767f33d7 100644 --- a/src/Velopack.Packaging/DeltaPackageBuilder.cs +++ b/src/Velopack.Packaging/DeltaPackageBuilder.cs @@ -1,6 +1,4 @@ using System.IO.MemoryMappedFiles; -using System.Runtime.ConstrainedExecution; -using System.Runtime.Intrinsics.Arm; using System.Text; using Microsoft.Extensions.Logging; using Velopack.Compression; diff --git a/src/Velopack.Packaging/PackageBuilder.cs b/src/Velopack.Packaging/PackageBuilder.cs index f10a06ed..d6b035b1 100644 --- a/src/Velopack.Packaging/PackageBuilder.cs +++ b/src/Velopack.Packaging/PackageBuilder.cs @@ -153,7 +153,12 @@ namespace Velopack.Packaging } foreach (var f in filesToCopy) { +#if NET6_0_OR_GREATER File.Move(f.from, f.to, true); +#else + File.Delete(f.to); + File.Move(f.from, f.to); +#endif } ReleaseEntryHelper.UpdateReleaseFiles(releaseDir.FullName, Log); diff --git a/src/Velopack.Packaging/ReleaseEntryHelper.cs b/src/Velopack.Packaging/ReleaseEntryHelper.cs index 86f3e184..32aa903c 100644 --- a/src/Velopack.Packaging/ReleaseEntryHelper.cs +++ b/src/Velopack.Packaging/ReleaseEntryHelper.cs @@ -1,12 +1,8 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using System.Text.RegularExpressions; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using NuGet.Versioning; using Velopack.Json; using Velopack.NuGet; using Velopack.Packaging.Exceptions; -using Velopack.Sources; namespace Velopack.Packaging { @@ -123,12 +119,16 @@ namespace Velopack.Packaging public static IEnumerable MergeAssets(IEnumerable priority, IEnumerable secondary) { +#if NET6_0_OR_GREATER return priority.Concat(secondary).DistinctBy(x => x.FileName); +#else + return priority.Concat(secondary).GroupBy(x => x.FileName).Select(g => g.First()); +#endif } public static string GetAssetFeedJson(VelopackAssetFeed feed) { - return JsonSerializer.Serialize(feed, SimpleJson.Options); + return SimpleJson.SerializeObject(feed); } public static string GetSuggestedReleaseName(string id, string version, string channel, bool delta) diff --git a/src/Velopack.Packaging/Velopack.Packaging.csproj b/src/Velopack.Packaging/Velopack.Packaging.csproj index 4426d1d7..ecda0fa2 100644 --- a/src/Velopack.Packaging/Velopack.Packaging.csproj +++ b/src/Velopack.Packaging/Velopack.Packaging.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net6.0;netstandard2.0 enable $(NoWarn);CA2007;CS8002 true diff --git a/src/Velopack.Vpk/Commands/_BaseCommand.cs b/src/Velopack.Vpk/Commands/_BaseCommand.cs index a38fc5d9..91085768 100644 --- a/src/Velopack.Vpk/Commands/_BaseCommand.cs +++ b/src/Velopack.Vpk/Commands/_BaseCommand.cs @@ -2,7 +2,7 @@ public class BaseCommand : CliCommand { - private Dictionary> _setters = new(); + private readonly Dictionary> _setters = new(); protected BaseCommand(string name, string description) : base(name, description) @@ -40,7 +40,7 @@ public class BaseCommand : CliCommand public virtual ParseResult ParseAndApply(string command) { - var x = this.Parse(command); + var x = Parse(command); SetProperties(x); return x; } diff --git a/src/Velopack.Vpk/Logging/BasicConsole.cs b/src/Velopack.Vpk/Logging/BasicConsole.cs index 4b7c0134..15c48e6f 100644 --- a/src/Velopack.Vpk/Logging/BasicConsole.cs +++ b/src/Velopack.Vpk/Logging/BasicConsole.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Spectre.Console; -using Velopack.Packaging.Abstractions; +using Velopack.Packaging.Abstractions; namespace Velopack.Vpk.Logging { diff --git a/src/Velopack/Locators/WindowsVelopackLocator.cs b/src/Velopack/Locators/WindowsVelopackLocator.cs index 202583d6..c45c651f 100644 --- a/src/Velopack/Locators/WindowsVelopackLocator.cs +++ b/src/Velopack/Locators/WindowsVelopackLocator.cs @@ -57,10 +57,10 @@ namespace Velopack.Locators ourExePath = Path.GetFullPath(ourExePath); string myDirPath = Path.GetDirectoryName(ourExePath)!; var myDirName = Path.GetFileName(myDirPath); - var possibleUpdateExe = Path.GetFullPath(Path.Combine(myDirPath, "..\\Update.exe")); + var possibleUpdateExe = Path.GetFullPath(Path.Combine(myDirPath, "..", "Update.exe")); var ixCurrent = ourExePath.LastIndexOf("/current/", StringComparison.InvariantCultureIgnoreCase); - Log.Info($"Initialising {nameof(WindowsVelopackLocator)}"); + Log.Info($"Initializing {nameof(WindowsVelopackLocator)}"); if (File.Exists(possibleUpdateExe)) { Log.Info("Update.exe found in parent directory"); diff --git a/src/Velopack/ReleaseEntry.cs b/src/Velopack/ReleaseEntry.cs index a4bdad24..05b6ef27 100644 --- a/src/Velopack/ReleaseEntry.cs +++ b/src/Velopack/ReleaseEntry.cs @@ -163,7 +163,7 @@ namespace Velopack ///// ///// Given a local directory containing a package corresponding to this release, returns the - ///// correspoding release notes from within the package. + ///// corresponding release notes from within the package. ///// //public string GetReleaseNotes(string packageDirectory, ReleaseNotesFormat format) //{ @@ -294,7 +294,7 @@ namespace Velopack /// /// Parse the contents of a RELEASES file into a list of 's, - /// with any staging-uneligible releases removed. + /// with any staging-ineligible releases removed. /// public static IEnumerable ParseReleaseFileAndApplyStaging(string fileContents, Guid? userToken) { diff --git a/src/Velopack/Sources/SimpleWebSource.cs b/src/Velopack/Sources/SimpleWebSource.cs index 8f68b34e..ff2e91ce 100644 --- a/src/Velopack/Sources/SimpleWebSource.cs +++ b/src/Velopack/Sources/SimpleWebSource.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; namespace Velopack.Sources { diff --git a/src/Velopack/UpdateExe.cs b/src/Velopack/UpdateExe.cs index ed78edf1..84d80052 100644 --- a/src/Velopack/UpdateExe.cs +++ b/src/Velopack/UpdateExe.cs @@ -68,11 +68,13 @@ namespace Velopack var p = Process.Start(psi); - try { - // this is an attempt to work around a bug where the restarted app fails to come to foreground. - AllowSetForegroundWindow(p.Id); - } catch (Exception ex) { - logger.LogWarning(ex, "Failed to allow Update.exe to set foreground window."); + if (p is not null) { + try { + // this is an attempt to work around a bug where the restarted app fails to come to foreground. + AllowSetForegroundWindow(p.Id); + } catch (Exception ex) { + logger.LogWarning(ex, "Failed to allow Update.exe to set foreground window."); + } } Thread.Sleep(300); diff --git a/src/Velopack/UpdateManager.cs b/src/Velopack/UpdateManager.cs index 049986bb..8fac4974 100644 --- a/src/Velopack/UpdateManager.cs +++ b/src/Velopack/UpdateManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; diff --git a/src/Velopack/VelopackAsset.cs b/src/Velopack/VelopackAsset.cs index 95eeb03a..b85a397b 100644 --- a/src/Velopack/VelopackAsset.cs +++ b/src/Velopack/VelopackAsset.cs @@ -26,7 +26,7 @@ namespace Velopack /// /// A list of assets available in this feed. /// - public VelopackAsset[] Assets { get; init; } = new VelopackAsset[0]; + public VelopackAsset[] Assets { get; init; } = Array.Empty(); /// /// Parse a json string into a .