mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Merge branch 'master' into develop
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(MSBuildProjectExtension)'=='.csproj' ">
|
||||
<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.119" PrivateAssets="All" />
|
||||
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.*" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -13,17 +13,17 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AWSSDK.S3" Version="3.7.101.26" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||
<PackageReference Include="AWSSDK.S3" Version="3.7.205.22" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Octokit" Version="4.0.2" />
|
||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
|
||||
<PackageReference Include="System.IO" Version="4.3.0" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
|
||||
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
|
||||
<PackageReference Include="NuGet.Commands" Version="6.4.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||
<PackageReference Include="PeNet" Version="2.9.9" />
|
||||
<PackageReference Include="NuGet.Commands" Version="6.7.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
|
||||
<PackageReference Include="PeNet" Version="4.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
@@ -18,13 +18,11 @@ namespace Squirrel
|
||||
public enum DotnetRuntimeType
|
||||
{
|
||||
/// <summary> The .NET Runtime contains just the components needed to run a console app </summary>
|
||||
DotNet = 1,
|
||||
Runtime = 1,
|
||||
/// <summary> The The ASP.NET Core Runtime enables you to run existing web/server applications </summary>
|
||||
AspNetCore,
|
||||
/// <summary> The .NET Desktop Runtime enables you to run existing Windows desktop applications </summary>
|
||||
WindowsDesktop,
|
||||
/// <summary> The .NET SDK enables you to compile dotnet applications you intend to run on other systems </summary>
|
||||
SDK,
|
||||
}
|
||||
|
||||
/// <summary> Runtime installation result code </summary>
|
||||
@@ -177,8 +175,7 @@ namespace Squirrel
|
||||
public DotnetRuntimeType RuntimeType { get; }
|
||||
|
||||
private static readonly Dictionary<DotnetRuntimeType, string> _runtimeShortForm = new() {
|
||||
{ DotnetRuntimeType.DotNet, "base" },
|
||||
{ DotnetRuntimeType.SDK, "sdk" },
|
||||
{ DotnetRuntimeType.Runtime, "runtime" },
|
||||
{ DotnetRuntimeType.WindowsDesktop, "desktop" },
|
||||
{ DotnetRuntimeType.AspNetCore, "asp" },
|
||||
};
|
||||
@@ -252,10 +249,9 @@ namespace Squirrel
|
||||
return null;
|
||||
|
||||
return runtimeType switch {
|
||||
DotnetRuntimeType.DotNet => Path.Combine(baseDir, "shared", "Microsoft.NETCore.App"),
|
||||
DotnetRuntimeType.Runtime => Path.Combine(baseDir, "shared", "Microsoft.NETCore.App"),
|
||||
DotnetRuntimeType.AspNetCore => Path.Combine(baseDir, "shared", "Microsoft.AspNetCore.App"),
|
||||
DotnetRuntimeType.WindowsDesktop => Path.Combine(baseDir, "shared", "Microsoft.WindowsDesktop.App"),
|
||||
DotnetRuntimeType.SDK => Path.Combine(baseDir, "sdk"),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(DotnetRuntimeType)),
|
||||
};
|
||||
}
|
||||
@@ -292,6 +288,8 @@ namespace Squirrel
|
||||
/// <inheritdoc/>
|
||||
public override async Task<string> GetDownloadUrl()
|
||||
{
|
||||
// Note that GetLatestDotNetVersion should still be fixed for WindowsDesktop as it is the only url that the azure
|
||||
// blob responds with the latest version. This doesn't matter as all dotnet needed runtimes will have the same latest version.
|
||||
var latest = await GetLatestDotNetVersion(DotnetRuntimeType.WindowsDesktop, $"{MinVersion.Major}.{MinVersion.Minor}").ConfigureAwait(false);
|
||||
var architecture = CpuArchitecture switch {
|
||||
RuntimeCpu.x86 => "x86",
|
||||
@@ -300,10 +298,10 @@ namespace Squirrel
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(CpuArchitecture)),
|
||||
};
|
||||
|
||||
return GetDotNetDownloadUrl(DotnetRuntimeType.WindowsDesktop, latest, architecture);
|
||||
return GetDotNetDownloadUrl(RuntimeType, latest, architecture);
|
||||
}
|
||||
|
||||
private static Regex _dotnetRegex = new Regex(@"^net(?:coreapp)?(?<version>[\d\.]{1,7})(?:-(?<arch>[\w\d]+))?(?:-(?<type>\w+))?$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
private static Regex _dotnetRegex = new Regex(@"^net(?:coreapp)?(?<version>[\d\.]{1,7})(?:-(?<arch>[a-zA-Z]+\d\d))?(?:-(?<type>[a-zA-Z]+))?$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
/// <summary>
|
||||
/// Parses a string such as 'net6' or net5.0.14-x86 into a DotnetInfo class capable of checking
|
||||
@@ -365,11 +363,6 @@ namespace Squirrel
|
||||
throw new ArgumentException("Version must only be a 3-part version string.", nameof(input));
|
||||
|
||||
if ((v.Major == 3 && v.Minor == 1) || v.Major >= 5) {
|
||||
if (v.Major > 8) {
|
||||
Log.Warn(
|
||||
$"Runtime version '{input}' was resolved to major version '{v.Major}', but this is greater than any known dotnet version, " +
|
||||
$"and if this version does not exist this package may fail to install.");
|
||||
}
|
||||
return v;
|
||||
}
|
||||
throw new ArgumentException($"Version must be 3.1 or >= 5.0. (Actual: {v})", nameof(input));
|
||||
@@ -404,10 +397,9 @@ namespace Squirrel
|
||||
// https://github.com/dotnet/install-scripts/blob/main/src/dotnet-install.ps1#L427
|
||||
// these are case sensitive
|
||||
string runtime = runtimeType switch {
|
||||
DotnetRuntimeType.DotNet => "dotnet",
|
||||
DotnetRuntimeType.Runtime => "dotnet",
|
||||
DotnetRuntimeType.AspNetCore => "aspnetcore",
|
||||
DotnetRuntimeType.WindowsDesktop => "WindowsDesktop",
|
||||
DotnetRuntimeType.SDK => "Sdk",
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
|
||||
@@ -429,13 +421,12 @@ namespace Squirrel
|
||||
{
|
||||
// https://github.com/dotnet/install-scripts/blob/main/src/dotnet-install.ps1#L619
|
||||
return runtimeType switch {
|
||||
DotnetRuntimeType.DotNet => $"{DotNetFeed}/Runtime/{version}/dotnet-runtime-{version}-win-{cpuarch}.exe",
|
||||
DotnetRuntimeType.Runtime => $"{DotNetFeed}/Runtime/{version}/dotnet-runtime-{version}-win-{cpuarch}.exe",
|
||||
DotnetRuntimeType.AspNetCore => $"{DotNetFeed}/aspnetcore/Runtime/{version}/aspnetcore-runtime-{version}-win-{cpuarch}.exe",
|
||||
DotnetRuntimeType.WindowsDesktop =>
|
||||
new Version(version).Major >= 5
|
||||
? $"{DotNetFeed}/WindowsDesktop/{version}/windowsdesktop-runtime-{version}-win-{cpuarch}.exe"
|
||||
: $"{DotNetFeed}/Runtime/{version}/windowsdesktop-runtime-{version}-win-{cpuarch}.exe",
|
||||
DotnetRuntimeType.SDK => $"{DotNetFeed}/Sdk/{version}/dotnet-sdk-{version}-win-{cpuarch}.exe",
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,14 +12,19 @@ namespace Squirrel
|
||||
public static partial class Runtimes
|
||||
{
|
||||
/// <summary> Runtime for .NET Framework 4.5 </summary>
|
||||
[Obsolete("EOL")]
|
||||
public static readonly FrameworkInfo NETFRAMEWORK45 = new("net45", ".NET Framework 4.5", "http://go.microsoft.com/fwlink/?LinkId=397707", 378389);
|
||||
/// <summary> Runtime for .NET Framework 4.5.1 </summary>
|
||||
[Obsolete("EOL")]
|
||||
public static readonly FrameworkInfo NETFRAMEWORK451 = new("net451", ".NET Framework 4.5.1", "http://go.microsoft.com/fwlink/?LinkId=397707", 378675);
|
||||
/// <summary> Runtime for .NET Framework 4.5.2 </summary>
|
||||
[Obsolete("EOL")]
|
||||
public static readonly FrameworkInfo NETFRAMEWORK452 = new("net452", ".NET Framework 4.5.2", "http://go.microsoft.com/fwlink/?LinkId=397707", 379893);
|
||||
/// <summary> Runtime for .NET Framework 4.6 </summary>
|
||||
[Obsolete("EOL")]
|
||||
public static readonly FrameworkInfo NETFRAMEWORK46 = new("net46", ".NET Framework 4.6", "http://go.microsoft.com/fwlink/?LinkId=780596", 393295);
|
||||
/// <summary> Runtime for .NET Framework 4.6.1 </summary>
|
||||
[Obsolete("EOL")]
|
||||
public static readonly FrameworkInfo NETFRAMEWORK461 = new("net461", ".NET Framework 4.6.1", "http://go.microsoft.com/fwlink/?LinkId=780596", 394254);
|
||||
/// <summary> Runtime for .NET Framework 4.6.2 </summary>
|
||||
public static readonly FrameworkInfo NETFRAMEWORK462 = new("net462", ".NET Framework 4.6.2", "http://go.microsoft.com/fwlink/?LinkId=780596", 394802);
|
||||
@@ -31,15 +36,21 @@ namespace Squirrel
|
||||
public static readonly FrameworkInfo NETFRAMEWORK472 = new("net472", ".NET Framework 4.7.2", "http://go.microsoft.com/fwlink/?LinkId=863262", 461808);
|
||||
/// <summary> Runtime for .NET Framework 4.8 </summary>
|
||||
public static readonly FrameworkInfo NETFRAMEWORK48 = new("net48", ".NET Framework 4.8", "http://go.microsoft.com/fwlink/?LinkId=2085155", 528040);
|
||||
/// <summary> Runtime for .NET Framework 4.8.1 </summary>
|
||||
public static readonly FrameworkInfo NETFRAMEWORK481 = new("net481", ".NET Framework 4.8.1", "http://go.microsoft.com/fwlink/?LinkId=2203304", 533320);
|
||||
|
||||
|
||||
/// <summary> Runtime for .NET Core 3.1 Desktop Runtime (x86) </summary>
|
||||
[Obsolete("EOL")]
|
||||
public static readonly DotnetInfo DOTNETCORE31_X86 = new("3.1", RuntimeCpu.x86); // eg. netcoreapp3.1-x86
|
||||
/// <summary> Runtime for .NET Core 3.1 Desktop Runtime (x64) </summary>
|
||||
[Obsolete("EOL")]
|
||||
public static readonly DotnetInfo DOTNETCORE31_X64 = new("3.1", RuntimeCpu.x64); // eg. netcoreapp3.1-x64
|
||||
/// <summary> Runtime for .NET 5.0 Desktop Runtime (x86) </summary>
|
||||
[Obsolete("EOL")]
|
||||
public static readonly DotnetInfo DOTNET5_X86 = new("5.0", RuntimeCpu.x86); // eg. net5.0-x86
|
||||
/// <summary> Runtime for .NET 5.0 Desktop Runtime (x64) </summary>
|
||||
[Obsolete("EOL")]
|
||||
public static readonly DotnetInfo DOTNET5_X64 = new("5.0", RuntimeCpu.x64); // eg. net5.0-x64
|
||||
/// <summary> Runtime for .NET 6.0 Desktop Runtime (x86) </summary>
|
||||
public static readonly DotnetInfo DOTNET6_X86 = new("6.0.2", RuntimeCpu.x86); // eg. net6.0-x86
|
||||
@@ -53,6 +64,12 @@ namespace Squirrel
|
||||
public static readonly DotnetInfo DOTNET7_X64 = new("7.0", RuntimeCpu.x64); // eg. net7.0-x64
|
||||
/// <summary> Runtime for .NET 7.0 Desktop Runtime (arm64) </summary>
|
||||
public static readonly DotnetInfo DOTNET7_ARM64 = new("7.0", RuntimeCpu.arm64); // eg. net7.0-arm64
|
||||
/// <summary> Runtime for .NET 8.0 Desktop Runtime (x86) </summary>
|
||||
public static readonly DotnetInfo DOTNET8_X86 = new("8.0", RuntimeCpu.x86); // eg. net8.0-x86
|
||||
/// <summary> Runtime for .NET 8.0 Desktop Runtime (x64) </summary>
|
||||
public static readonly DotnetInfo DOTNET8_X64 = new("8.0", RuntimeCpu.x64); // eg. net8.0-x64
|
||||
/// <summary> Runtime for .NET 8.0 Desktop Runtime (arm64) </summary>
|
||||
public static readonly DotnetInfo DOTNET8_ARM64 = new("8.0", RuntimeCpu.arm64); // eg. net8.0-arm64
|
||||
|
||||
|
||||
/// <summary> Runtime for Visual C++ 2010 Redistributable (x86) </summary>
|
||||
|
||||
233
src/Squirrel/Sources/GitlabSource.cs
Normal file
233
src/Squirrel/Sources/GitlabSource.cs
Normal file
@@ -0,0 +1,233 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using Squirrel.Json;
|
||||
|
||||
namespace Squirrel.Sources
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a Gitlab release, plus any assets that are attached.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public class GitlabRelease
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the release.
|
||||
/// </summary>
|
||||
[DataMember(Name = "name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// True if this is intended for an upcoming release.
|
||||
/// </summary>
|
||||
[DataMember(Name = "upcoming_release")]
|
||||
public bool UpcomingRelease { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The date which this release was published publically.
|
||||
/// </summary>
|
||||
[DataMember(Name = "released_at")]
|
||||
public DateTime ReleasedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A container for the assets (files) uploaded to this release.
|
||||
/// </summary>
|
||||
[DataMember(Name = "assets")]
|
||||
public GitlabReleaseAsset Assets { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes a container for the assets attached to a release.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public class GitlabReleaseAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// The amount of assets linked to the release.
|
||||
/// </summary>
|
||||
[DataMember(Name = "count")]
|
||||
public int Count { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A list of asset (file) links.
|
||||
/// </summary>
|
||||
[DataMember(Name = "links")]
|
||||
public GitlabReleaseLink[] Links { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes a container for the links of assets attached to a release.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public class GitlabReleaseLink
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the asset (file) linked.
|
||||
/// </summary>
|
||||
[DataMember(Name = "name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The url for the asset. This make use of the Gitlab API.
|
||||
/// </summary>
|
||||
[DataMember(Name = "url")]
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A direct url to the asset, via a traditional URl.
|
||||
/// As a posed to using the API.
|
||||
/// This links directly to the raw asset (file).
|
||||
/// </summary>
|
||||
[DataMember(Name = "direct_asset_url")]
|
||||
public string DirectAssetUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The category type that the asset is listed under.
|
||||
/// Options: 'Package', 'Image', 'Runbook', 'Other'
|
||||
/// </summary>
|
||||
[DataMember(Name = "link_type")]
|
||||
public string Type { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves available releases from a GitLab repository. This class only
|
||||
/// downloads assets from the very latest GitLab release.
|
||||
/// </summary>
|
||||
public class GitlabSource : IUpdateSource
|
||||
{
|
||||
/// <summary>
|
||||
/// The URL of the GitLab repository to download releases from
|
||||
/// (e.g. https://gitlab.com/api/v4/projects/ProjectId)
|
||||
/// </summary>
|
||||
public virtual Uri RepoUri { get; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, the latest upcoming release will be downloaded. If false, the latest
|
||||
/// stable release will be downloaded.
|
||||
/// </summary>
|
||||
public virtual bool UpcomingRelease { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The file downloader used to perform HTTP requests.
|
||||
/// </summary>
|
||||
public virtual IFileDownloader Downloader { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The GitLab release which this class should download assets from when
|
||||
/// executing <see cref="DownloadReleaseEntry"/>. This property can be set
|
||||
/// explicitly, otherwise it will also be set automatically when executing
|
||||
/// <see cref="GetReleaseFeed(Guid?, ReleaseEntry)"/>.
|
||||
/// </summary>
|
||||
public virtual GitlabRelease Release { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The GitLab access token to use with the request to download releases.
|
||||
/// </summary>
|
||||
protected virtual string AccessToken { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Bearer token used in the request.
|
||||
/// </summary>
|
||||
protected virtual string Authorization => string.IsNullOrWhiteSpace(AccessToken) ? null : "Bearer " + AccessToken;
|
||||
|
||||
/// <inheritdoc cref="GitlabSource" />
|
||||
/// <param name="repoUrl">
|
||||
/// The URL of the GitLab repository to download releases from
|
||||
/// (e.g. https://gitlab.com/api/v4/projects/ProjectId)
|
||||
/// </param>
|
||||
/// <param name="accessToken">
|
||||
/// The GitLab access token to use with the request to download releases.
|
||||
/// </param>
|
||||
/// <param name="upcomingRelease">
|
||||
/// If true, the latest upcoming release will be downloaded. If false, the latest
|
||||
/// stable release will be downloaded.
|
||||
/// </param>
|
||||
/// <param name="downloader">
|
||||
/// The file downloader used to perform HTTP requests.
|
||||
/// </param>
|
||||
public GitlabSource(string repoUrl, string accessToken, bool upcomingRelease, IFileDownloader downloader = null)
|
||||
{
|
||||
RepoUri = new Uri(repoUrl);
|
||||
AccessToken = accessToken;
|
||||
UpcomingRelease = upcomingRelease;
|
||||
Downloader = downloader ?? Utility.CreateDefaultDownloader();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task DownloadReleaseEntry(ReleaseEntry releaseEntry, string localFile, Action<int> progress)
|
||||
{
|
||||
if (Release == null) {
|
||||
throw new InvalidOperationException("No GitLab Release specified. Call GetReleaseFeed or set " +
|
||||
"GitLabSource.Release before calling this function.");
|
||||
}
|
||||
|
||||
var assetUrl = GetAssetUrlFromName(Release, releaseEntry.Filename);
|
||||
return Downloader.DownloadFile(assetUrl, localFile, progress, Authorization, "application/octet-stream");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<ReleaseEntry[]> GetReleaseFeed(Guid? stagingId = null, ReleaseEntry latestLocalRelease = null)
|
||||
{
|
||||
var releases = await GetReleases(UpcomingRelease).ConfigureAwait(false);
|
||||
if (releases == null || releases.Count() == 0)
|
||||
throw new Exception($"No Gitlab releases found at '{RepoUri}'.");
|
||||
|
||||
// CS: we 'cache' the release here, so subsequent calls to DownloadReleaseEntry
|
||||
// will download assets from the same release in which we returned ReleaseEntry's
|
||||
// from. A better architecture would be to return an array of "GitlabReleaseEntry"
|
||||
// containing a reference to the GitlabReleaseAsset instead.
|
||||
Release = releases.First();
|
||||
|
||||
var assetUrl = GetAssetUrlFromName(Release, "RELEASES");
|
||||
var releaseBytes = await Downloader.DownloadBytes(assetUrl, Authorization, "application/octet-stream").ConfigureAwait(false);
|
||||
var txt = Utility.RemoveByteOrderMarkerIfPresent(releaseBytes);
|
||||
return ReleaseEntry.ParseReleaseFileAndApplyStaging(txt, stagingId).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Given a <see cref="GitlabRelease"/> and an asset filename (eg. 'RELEASES') this
|
||||
/// function will return either <see cref="GitlabReleaseLink.DirectAssetUrl"/> or
|
||||
/// <see cref="GitlabReleaseLink.Url"/>, depending whether an access token is available
|
||||
/// or not. Throws if the specified release has no matching assets.
|
||||
/// </summary>
|
||||
protected virtual string GetAssetUrlFromName(GitlabRelease release, string assetName)
|
||||
{
|
||||
if (release.Assets == null || release.Assets.Count == 0)
|
||||
{
|
||||
throw new ArgumentException($"No assets found in Gitlab Release '{release.Name}'.");
|
||||
}
|
||||
|
||||
GitlabReleaseLink packageFile =
|
||||
release.Assets.Links.FirstOrDefault(a => a.Name.Equals(assetName, StringComparison.InvariantCultureIgnoreCase));
|
||||
if (packageFile == null)
|
||||
{
|
||||
throw new ArgumentException($"Could not find asset called '{assetName}' in GitLab Release '{release.Name}'.");
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(AccessToken))
|
||||
{
|
||||
return packageFile.DirectAssetUrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
return packageFile.Url;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a list of <see cref="GitlabRelease"/> from the current repository.
|
||||
/// </summary>
|
||||
public virtual async Task<GitlabRelease[]> GetReleases(bool includePrereleases, int perPage = 30, int page = 1)
|
||||
{
|
||||
// https://docs.gitlab.com/ee/api/releases/
|
||||
var releasesPath = $"{RepoUri.AbsolutePath}/releases?per_page={perPage}&page={page}";
|
||||
var baseUri = new Uri("https://gitlab.com");
|
||||
var getReleasesUri = new Uri(baseUri, releasesPath);
|
||||
var response = await Downloader.DownloadString(getReleasesUri.ToString(), Authorization).ConfigureAwait(false);
|
||||
var releases = SimpleJson.DeserializeObject<List<GitlabRelease>>(response);
|
||||
return releases.OrderByDescending(d => d.ReleasedAt).Where(x => includePrereleases || !x.UpcomingRelease).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,6 @@ namespace Squirrel.Sources
|
||||
if (releaseEntry == null) throw new ArgumentNullException(nameof(releaseEntry));
|
||||
if (localFile == null) throw new ArgumentNullException(nameof(localFile));
|
||||
|
||||
|
||||
var releaseUri = releaseEntry.BaseUrl == null
|
||||
? releaseEntry.Filename
|
||||
: Utility.AppendPathToUri(new Uri(releaseEntry.BaseUrl), releaseEntry.Filename).ToString();
|
||||
@@ -79,7 +78,10 @@ namespace Squirrel.Sources
|
||||
// releaseUri can be a relative url (eg. "MyPackage.nupkg") or it can be an
|
||||
// absolute url (eg. "https://example.com/MyPackage.nupkg"). In the former case
|
||||
var sourceBaseUri = Utility.EnsureTrailingSlash(BaseUri);
|
||||
var source = new Uri(sourceBaseUri, releaseUri).ToString();
|
||||
|
||||
var source = Utility.IsHttpUrl(releaseUri)
|
||||
? new Uri(sourceBaseUri, releaseUri).ToString()
|
||||
: Utility.AppendPathToUri(sourceBaseUri, releaseUri).ToString();
|
||||
|
||||
this.Log().Info($"Downloading '{releaseEntry.Filename}' from '{source}'.");
|
||||
return Downloader.DownloadFile(source, localFile, progress);
|
||||
|
||||
@@ -2,18 +2,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net461;netstandard2.0;net5.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net462;net48;netstandard2.0;net5.0;net6.0</TargetFrameworks>
|
||||
<AssemblyName>Squirrel.Core</AssemblyName>
|
||||
<Description>Squirrel</Description>
|
||||
<Title>Squirrel</Title>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageId>Clowd.Squirrel</PackageId>
|
||||
<Title>Squirrel Updater</Title>
|
||||
<Description>Quick and easy installer and automatic updates for desktop applications</Description>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<PackageIcon>Clowd_200.png</PackageIcon>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SharpCompress" Version="0.32.2" />
|
||||
<PackageReference Include="NuGet.Versioning" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -21,12 +24,22 @@
|
||||
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" $(TargetFramework) == 'net461' ">
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
|
||||
<Choose>
|
||||
<When Condition=" $(TargetFramework.StartsWith('net4')) ">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SharpCompress" Version="0.33.0" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SharpCompress" Version="0.34.1" />
|
||||
</ItemGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\..\docs\artwork\Clowd_200.png" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NLog" Version="5.1.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||
<PackageReference Include="Vanara.PInvoke.User32" Version="3.4.11" />
|
||||
<PackageReference Include="Vanara.PInvoke.SHCore" Version="3.4.11" />
|
||||
<PackageReference Include="Vanara.PInvoke.ComCtl32" Version="3.4.11" />
|
||||
<PackageReference Include="NLog" Version="5.2.5" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
|
||||
<PackageReference Include="Vanara.PInvoke.User32" Version="3.4.17" />
|
||||
<PackageReference Include="Vanara.PInvoke.SHCore" Version="3.4.17" />
|
||||
<PackageReference Include="Vanara.PInvoke.ComCtl32" Version="3.4.17" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Allow netframework binaries to be built explicitly using the command line -->
|
||||
|
||||
@@ -100,6 +100,7 @@ namespace Squirrel.Update.Windows
|
||||
private void ShowProc()
|
||||
{
|
||||
var config = new TASKDIALOGCONFIG();
|
||||
config.WindowTitle = AppName;
|
||||
config.dwCommonButtons = TASKDIALOG_COMMON_BUTTON_FLAGS.TDCBF_CANCEL_BUTTON;
|
||||
config.MainInstruction = "Installing " + AppName;
|
||||
//config.Content = "Hello this is some content";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
@@ -271,8 +271,8 @@ namespace Squirrel.Update.Windows
|
||||
_signal.Set(); // signal to calling thread that the window has been created
|
||||
|
||||
using (StartGifAnimation()) {
|
||||
bool bRet;
|
||||
while ((bRet = GetMessage(out msg, HWND.NULL, 0, 0)) != false) {
|
||||
int bRet;
|
||||
while ((bRet = GetMessage(out msg, HWND.NULL, 0, 0)) != 0) {
|
||||
if (msg.message == (uint) WM_QUIT)
|
||||
break;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Squirrel.Tests.TestHelpers;
|
||||
using Xunit;
|
||||
|
||||
@@ -143,5 +144,35 @@ namespace Squirrel.Tests
|
||||
await source.DownloadReleaseEntry(releases[0], "test", null);
|
||||
Assert.Equal(baseUrl + "/" + releases[0].Filename, new Uri(dl.LastUrl).GetLeftPart(UriPartial.Path));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("http://example.com", "MyPackage.nupkg", "http://example.com/MyPackage.nupkg")]
|
||||
[InlineData("http://example.com?auth=hello", "MyPackage.nupkg", "http://example.com/MyPackage.nupkg?auth=hello")]
|
||||
[InlineData("http://example.com?auth=hello", "https://my.packages.domain/MyPackage-1.0.0.nupkg", "https://my.packages.domain/MyPackage-1.0.0.nupkg")]
|
||||
public async Task SimpleWebSourcePreservesQueryParametersAndAbsoluteReleaseUri(string baseUri, string releaseUri, string expectedPackageUrl)
|
||||
{
|
||||
var dl = new FakeDownloader();
|
||||
var source = new Sources.SimpleWebSource(baseUri, dl);
|
||||
var baseKvp = HttpUtility.ParseQueryString(new Uri(baseUri).Query);
|
||||
var baseDict = baseKvp.AllKeys.Where(k => k != null).ToDictionary(k => k, k => baseKvp[k]);
|
||||
|
||||
var releaseEntry = $"94689fede03fed7ab59c24337673a27837f0c3ec {releaseUri} 1004502";
|
||||
dl.MockedResponseBytes = Encoding.UTF8.GetBytes(releaseEntry);
|
||||
|
||||
var releases = await source.GetReleaseFeed();
|
||||
var expected = new Uri(baseUri).GetLeftPart(UriPartial.Path).TrimEnd('/') + "/RELEASES";
|
||||
Assert.StartsWith(expected, dl.LastUrl);
|
||||
|
||||
// check that each query parameter in base url is in the releases string
|
||||
var releasesUri = new Uri(dl.LastUrl);
|
||||
var releasesKvp = HttpUtility.ParseQueryString(releasesUri.Query);
|
||||
var releasesDict = releasesKvp.AllKeys.Where(k => k != null).ToDictionary(k => k, k => releasesKvp[k]);
|
||||
foreach (var kvp in baseDict) {
|
||||
Assert.Equal(releasesDict[kvp.Key], kvp.Value);
|
||||
}
|
||||
|
||||
await source.DownloadReleaseEntry(releases[0], "test", null);
|
||||
Assert.Equal(expectedPackageUrl, dl.LastUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using Xunit;
|
||||
|
||||
namespace Squirrel.Tests
|
||||
@@ -20,9 +21,10 @@ namespace Squirrel.Tests
|
||||
[InlineData("net6.0.1-x86", "net6.0.1-x86-desktop")]
|
||||
[InlineData("net6.0.0", "net6-x64-desktop")]
|
||||
[InlineData("net6.0-x64-desktop", "net6.0.2-x64-desktop")]
|
||||
[InlineData("net7.0-x64-base", "net7-x64-base")]
|
||||
[InlineData("net7.0-x64-runtime", "net7-x64-runtime")]
|
||||
[InlineData("net7.0-x64-asp", "net7-x64-asp")]
|
||||
[InlineData("net7.0-x64-sdk", "net7-x64-sdk")]
|
||||
[InlineData("net7.0-desktop", "net7-x64-desktop")]
|
||||
[InlineData("net7.0-runtime", "net7-x64-runtime")]
|
||||
public void DotnetParsesValidVersions(string input, string expected)
|
||||
{
|
||||
var p = Runtimes.DotnetInfo.Parse(input);
|
||||
@@ -33,6 +35,7 @@ namespace Squirrel.Tests
|
||||
[InlineData("net3.2")]
|
||||
[InlineData("net4.9")]
|
||||
[InlineData("net6.0.0.4")]
|
||||
[InlineData("net7.0-x64-base")]
|
||||
[InlineData("net6-basd")]
|
||||
[InlineData("net6-x64-aakaka")]
|
||||
public void DotnetParseThrowsInvalidVersion(string input)
|
||||
@@ -57,11 +60,51 @@ namespace Squirrel.Tests
|
||||
[InlineData("", false)]
|
||||
[InlineData(null, false)]
|
||||
[InlineData("net6-x64", true)]
|
||||
[InlineData("net6-x64-sdk", true)]
|
||||
[InlineData("net6-x64-runtime", true)]
|
||||
[InlineData("net6-x64-desktop", true)]
|
||||
public void GetRuntimeTests(string input, bool expected)
|
||||
{
|
||||
var dn = Runtimes.GetRuntimeByName(input);
|
||||
Assert.Equal(expected, dn != null);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("3.1", RuntimeCpu.x86, Runtimes.DotnetRuntimeType.WindowsDesktop)]
|
||||
[InlineData("3.1", RuntimeCpu.x86, Runtimes.DotnetRuntimeType.Runtime)]
|
||||
[InlineData("3.1", RuntimeCpu.x86, Runtimes.DotnetRuntimeType.AspNetCore)]
|
||||
[InlineData("3.1", RuntimeCpu.x64, Runtimes.DotnetRuntimeType.WindowsDesktop)]
|
||||
[InlineData("3.1", RuntimeCpu.x64, Runtimes.DotnetRuntimeType.Runtime)]
|
||||
[InlineData("3.1", RuntimeCpu.x64, Runtimes.DotnetRuntimeType.AspNetCore)]
|
||||
[InlineData("5.0", RuntimeCpu.x86, Runtimes.DotnetRuntimeType.WindowsDesktop)]
|
||||
[InlineData("5.0", RuntimeCpu.x86, Runtimes.DotnetRuntimeType.Runtime)]
|
||||
[InlineData("5.0", RuntimeCpu.x86, Runtimes.DotnetRuntimeType.AspNetCore)]
|
||||
[InlineData("5.0", RuntimeCpu.x64, Runtimes.DotnetRuntimeType.WindowsDesktop)]
|
||||
[InlineData("5.0", RuntimeCpu.x64, Runtimes.DotnetRuntimeType.Runtime)]
|
||||
[InlineData("5.0", RuntimeCpu.x64, Runtimes.DotnetRuntimeType.AspNetCore)]
|
||||
[InlineData("7.0", RuntimeCpu.x86, Runtimes.DotnetRuntimeType.WindowsDesktop)]
|
||||
[InlineData("7.0", RuntimeCpu.x86, Runtimes.DotnetRuntimeType.Runtime)]
|
||||
[InlineData("7.0", RuntimeCpu.x86, Runtimes.DotnetRuntimeType.AspNetCore)]
|
||||
[InlineData("7.0", RuntimeCpu.x64, Runtimes.DotnetRuntimeType.WindowsDesktop)]
|
||||
[InlineData("7.0", RuntimeCpu.x64, Runtimes.DotnetRuntimeType.Runtime)]
|
||||
[InlineData("7.0", RuntimeCpu.x64, Runtimes.DotnetRuntimeType.AspNetCore)]
|
||||
public void MicrosoftReturnsValidDotnetDownload(string minversion, RuntimeCpu architecture, Runtimes.DotnetRuntimeType runtimeType)
|
||||
{
|
||||
var dni = new Runtimes.DotnetInfo(minversion, architecture, runtimeType);
|
||||
var url = dni.GetDownloadUrl().Result;
|
||||
|
||||
Assert.Contains(minversion, url, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains(architecture.ToString(), url, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (runtimeType == Runtimes.DotnetRuntimeType.Runtime)
|
||||
Assert.Matches(@"/dotnet-runtime-\d", url);
|
||||
else if (runtimeType == Runtimes.DotnetRuntimeType.AspNetCore)
|
||||
Assert.Matches(@"/aspnetcore-runtime-\d", url);
|
||||
else if (runtimeType == Runtimes.DotnetRuntimeType.WindowsDesktop)
|
||||
Assert.Matches(@"/windowsdesktop-runtime-\d", url);
|
||||
|
||||
using var hc = new HttpClient();
|
||||
var result = hc.GetAsync(url, HttpCompletionOption.ResponseHeadersRead).Result;
|
||||
result.EnsureSuccessStatusCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" PrivateAssets="All" />
|
||||
<PackageReference Include="System.IO.Packaging" Version="6.0.0" />
|
||||
<PackageReference Include="xunit" Version="2.6.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" PrivateAssets="All" />
|
||||
<PackageReference Include="System.IO.Packaging" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user