mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Adding netstandard 2.0 support for packaging projects
Minor code cleanup and spelling fixes
This commit is contained in:
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"=="" (
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class DownRepository<TDown> : IRepositoryCanDownload<TDown>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<NoWarn>$(NoWarn);CA2007;CS8002</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -204,7 +204,7 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<NoWarn>$(NoWarn);CA2007;CS8002</NoWarn>
|
||||
@@ -14,6 +14,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AsmResolver.DotNet" Version="5.5.0" />
|
||||
<PackageReference Include="AsmResolver.PE.Win32Resources" Version="5.5.0" />
|
||||
<PackageReference Include="System.Reflection.Metadata" Version="8.0.0" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -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<BuildAssets>(File.ReadAllText(path), SimpleJson.Options);
|
||||
return SimpleJson.DeserializeObject<BuildAssets>(File.ReadAllText(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<VelopackAsset> MergeAssets(IEnumerable<VelopackAsset> priority, IEnumerable<VelopackAsset> 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)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<NoWarn>$(NoWarn);CA2007;CS8002</NoWarn>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
public class BaseCommand : CliCommand
|
||||
{
|
||||
private Dictionary<CliOption, Action<ParseResult>> _setters = new();
|
||||
private readonly Dictionary<CliOption, Action<ParseResult>> _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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace Velopack
|
||||
|
||||
///// <summary>
|
||||
///// 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.
|
||||
///// </summary>
|
||||
//public string GetReleaseNotes(string packageDirectory, ReleaseNotesFormat format)
|
||||
//{
|
||||
@@ -294,7 +294,7 @@ namespace Velopack
|
||||
|
||||
/// <summary>
|
||||
/// Parse the contents of a RELEASES file into a list of <see cref="ReleaseEntry"/>'s,
|
||||
/// with any staging-uneligible releases removed.
|
||||
/// with any staging-ineligible releases removed.
|
||||
/// </summary>
|
||||
public static IEnumerable<ReleaseEntry> ParseReleaseFileAndApplyStaging(string fileContents, Guid? userToken)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -68,12 +68,14 @@ namespace Velopack
|
||||
|
||||
var p = Process.Start(psi);
|
||||
|
||||
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);
|
||||
if (p == null) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Velopack
|
||||
/// <summary>
|
||||
/// A list of assets available in this feed.
|
||||
/// </summary>
|
||||
public VelopackAsset[] Assets { get; init; } = new VelopackAsset[0];
|
||||
public VelopackAsset[] Assets { get; init; } = Array.Empty<VelopackAsset>();
|
||||
|
||||
/// <summary>
|
||||
/// Parse a json string into a <see cref="VelopackAssetFeed"/>.
|
||||
|
||||
Reference in New Issue
Block a user