mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Remove legacy command handler
This commit is contained in:
@@ -6,7 +6,6 @@ namespace Velopack.Vpk.Compat;
|
||||
|
||||
public class RunnerFactory
|
||||
{
|
||||
private const string CLOWD_PACKAGE_NAME = "Clowd.Squirrel";
|
||||
private const string NUGET_PACKAGE_NAME = "Velopack";
|
||||
private readonly ILogger _logger;
|
||||
private readonly IConfiguration _config;
|
||||
@@ -44,43 +43,12 @@ public class RunnerFactory
|
||||
|
||||
var version = new SdkVersionLocator(_logger).Search(solutionDir, NUGET_PACKAGE_NAME);
|
||||
|
||||
if (version.Major == 4) {
|
||||
var myVer = VelopackRuntimeInfo.VelopackNugetVersion;
|
||||
if (version != myVer) {
|
||||
_logger.Warn($"Installed SDK is {version}, while vpk is {myVer}, this is not recommended.");
|
||||
}
|
||||
return new EmbeddedRunner(_logger);
|
||||
var myVer = VelopackRuntimeInfo.VelopackNugetVersion;
|
||||
if (version != myVer) {
|
||||
_logger.Warn($"Installed SDK is {version}, while vpk is {myVer}, this is not recommended when building packages.");
|
||||
}
|
||||
|
||||
if (version.Major == 2 && version.Minor > 7) {
|
||||
_logger.Warn("Running in V2 compatibility mode. Not all features may be available.");
|
||||
|
||||
Dictionary<string, string> packageSearchPaths = new();
|
||||
var nugetPackagesDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget", "packages");
|
||||
packageSearchPaths.Add("nuget user profile cache", Path.Combine(nugetPackagesDir, NUGET_PACKAGE_NAME.ToLower(), "{0}", "tools"));
|
||||
packageSearchPaths.Add("visual studio packages cache", Path.Combine(solutionDir, "packages", NUGET_PACKAGE_NAME + ".{0}", "tools"));
|
||||
string squirrelExe = null;
|
||||
|
||||
foreach (var kvp in packageSearchPaths) {
|
||||
var path = String.Format(kvp.Value, version);
|
||||
if (Directory.Exists(path)) {
|
||||
_logger.Debug($"Found {NUGET_PACKAGE_NAME} {version} from {kvp.Key}");
|
||||
var toolExePath = Path.Combine(path, "Squirrel.exe");
|
||||
if (File.Exists(toolExePath)) {
|
||||
squirrelExe = toolExePath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (squirrelExe is null) {
|
||||
throw new Exception($"Could not find {NUGET_PACKAGE_NAME} {version} Squirrel.exe");
|
||||
}
|
||||
|
||||
return new V2CompatRunner(_logger, squirrelExe);
|
||||
}
|
||||
|
||||
throw new NotSupportedException($"Squirrel {version} is installed in this project, but not supported by this version of Csq. Supported versions are [>= v2.8] and [>= v4.0]");
|
||||
return new EmbeddedRunner(_logger);
|
||||
}
|
||||
|
||||
private string FindSolutionDirectory(string slnArgument)
|
||||
|
||||
@@ -1,233 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
using Velopack.Vpk.Commands;
|
||||
|
||||
namespace Velopack.Vpk.Compat;
|
||||
|
||||
public class V2CompatRunner : EmbeddedRunner
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly string _squirrelExePath;
|
||||
|
||||
public V2CompatRunner(ILogger logger, string squirrelExePath)
|
||||
: base(logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_squirrelExePath = squirrelExePath;
|
||||
}
|
||||
|
||||
public override async Task ExecutePackWindows(WindowsPackCommand command)
|
||||
{
|
||||
if (!VelopackRuntimeInfo.IsWindows || command.GetRuntimeOs() != RuntimeOs.Windows) {
|
||||
throw new NotSupportedException("Squirrel v2.x is only supported on/for Windows.");
|
||||
}
|
||||
|
||||
var options = new PackOptions {
|
||||
releaseDir = command.GetReleaseDirectory().FullName,
|
||||
package = command.Package,
|
||||
framework = command.Runtimes,
|
||||
splashImage = command.SplashImage,
|
||||
icon = command.Icon,
|
||||
noDelta = command.Delta == Packaging.DeltaMode.None,
|
||||
allowUnaware = false,
|
||||
signParams = command.SignParameters,
|
||||
signTemplate = command.SignTemplate,
|
||||
packId = command.PackId,
|
||||
includePdb = command.IncludePdb,
|
||||
packAuthors = command.PackAuthors,
|
||||
packDirectory = command.PackDirectory,
|
||||
packTitle = command.PackTitle,
|
||||
packVersion = command.PackVersion,
|
||||
releaseNotes = command.ReleaseNotes,
|
||||
};
|
||||
|
||||
var args = new List<string> { "pack" };
|
||||
options.AddArgs(args);
|
||||
_logger.Debug($"Running V2 Squirrel.exe: '{_squirrelExePath} {String.Join(" ", args)}'");
|
||||
await Process.Start(_squirrelExePath, args).WaitForExitAsync();
|
||||
}
|
||||
|
||||
public override async Task ExecuteReleasifyWindows(WindowsReleasifyCommand command)
|
||||
{
|
||||
if (!VelopackRuntimeInfo.IsWindows || command.GetRuntimeOs() != RuntimeOs.Windows) {
|
||||
throw new NotSupportedException("Squirrel v2.x is only supported on/for Windows.");
|
||||
}
|
||||
|
||||
var options = new ReleasifyOptions {
|
||||
releaseDir = command.GetReleaseDirectory().FullName,
|
||||
package = command.Package,
|
||||
framework = command.Runtimes,
|
||||
splashImage = command.SplashImage,
|
||||
icon = command.Icon,
|
||||
noDelta = command.Delta == Packaging.DeltaMode.None,
|
||||
allowUnaware = false,
|
||||
signParams = command.SignParameters,
|
||||
signTemplate = command.SignTemplate,
|
||||
};
|
||||
|
||||
var args = new List<string> { "releasify" };
|
||||
options.AddArgs(args);
|
||||
_logger.Debug($"Running V2 Squirrel.exe: '{_squirrelExePath} {String.Join(" ", args)}'");
|
||||
await Process.Start(_squirrelExePath, args).WaitForExitAsync();
|
||||
}
|
||||
|
||||
public override Task ExecuteBundleOsx(OsxBundleCommand command)
|
||||
{
|
||||
throw new NotSupportedException("Squirrel v2.x is only supported on/for Windows.");
|
||||
}
|
||||
|
||||
public override Task ExecuteReleasifyOsx(OsxReleasifyCommand command)
|
||||
{
|
||||
throw new NotSupportedException("Squirrel v2.x is only supported on/for Windows.");
|
||||
}
|
||||
|
||||
private abstract class BaseOptions
|
||||
{
|
||||
public string releaseDir { get; set; }
|
||||
|
||||
public virtual void AddArgs(List<string> args)
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(releaseDir)) {
|
||||
args.Add("--releaseDir");
|
||||
args.Add(releaseDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class SigningOptions : BaseOptions
|
||||
{
|
||||
public string signParams { get; set; }
|
||||
public string signTemplate { get; set; }
|
||||
|
||||
public override void AddArgs(List<string> args)
|
||||
{
|
||||
base.AddArgs(args);
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(signParams)) {
|
||||
args.Add("--signParams");
|
||||
args.Add(signParams);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(signTemplate)) {
|
||||
args.Add("--signTemplate");
|
||||
args.Add(signTemplate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ReleasifyOptions : SigningOptions
|
||||
{
|
||||
public string package { get; set; }
|
||||
public string baseUrl { get; set; }
|
||||
public string framework { get; set; }
|
||||
public string splashImage { get; set; }
|
||||
public string icon { get; set; }
|
||||
public string appIcon { get; set; }
|
||||
public bool noDelta { get; set; }
|
||||
public bool allowUnaware { get; set; }
|
||||
public string msi { get; set; }
|
||||
public string debugSetupExe { get; set; }
|
||||
|
||||
public override void AddArgs(List<string> args)
|
||||
{
|
||||
base.AddArgs(args);
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(package)) {
|
||||
args.Add("--package");
|
||||
args.Add(package);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(baseUrl)) {
|
||||
args.Add("--baseUrl");
|
||||
args.Add(baseUrl);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(framework)) {
|
||||
args.Add("--framework");
|
||||
args.Add(framework);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(splashImage)) {
|
||||
args.Add("--splashImage");
|
||||
args.Add(splashImage);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(icon)) {
|
||||
args.Add("--icon");
|
||||
args.Add(icon);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(appIcon)) {
|
||||
args.Add("--appIcon");
|
||||
args.Add(appIcon);
|
||||
}
|
||||
|
||||
if (noDelta) {
|
||||
args.Add("--noDelta");
|
||||
}
|
||||
|
||||
if (allowUnaware) {
|
||||
args.Add("--allowUnaware");
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(msi)) {
|
||||
args.Add("--msi");
|
||||
args.Add(msi);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(debugSetupExe)) {
|
||||
args.Add("--debugSetupExe");
|
||||
args.Add(debugSetupExe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PackOptions : ReleasifyOptions
|
||||
{
|
||||
public string packId { get; set; }
|
||||
public string packTitle { get; set; }
|
||||
public string packVersion { get; set; }
|
||||
public string packAuthors { get; set; }
|
||||
public string packDirectory { get; set; }
|
||||
public bool includePdb { get; set; }
|
||||
public string releaseNotes { get; set; }
|
||||
|
||||
public override void AddArgs(List<string> args)
|
||||
{
|
||||
base.AddArgs(args);
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(packId)) {
|
||||
args.Add("--packId");
|
||||
args.Add(packId);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(packTitle)) {
|
||||
args.Add("--packTitle");
|
||||
args.Add(packTitle);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(packVersion)) {
|
||||
args.Add("--packVersion");
|
||||
args.Add(packVersion);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(packAuthors)) {
|
||||
args.Add("--packAuthors");
|
||||
args.Add(packAuthors);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(packDirectory)) {
|
||||
args.Add("--packDir");
|
||||
args.Add(packDirectory);
|
||||
}
|
||||
|
||||
if (includePdb) {
|
||||
args.Add("--includePdb");
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(releaseNotes)) {
|
||||
args.Add("--releaseNotes");
|
||||
args.Add(releaseNotes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class Program
|
||||
Configuration = new ConfigurationManager(),
|
||||
});
|
||||
|
||||
builder.Configuration.AddEnvironmentVariables("CSQ_");
|
||||
builder.Configuration.AddEnvironmentVariables("VPK_");
|
||||
|
||||
var minLevel = verbose ? LogEventLevel.Debug : LogEventLevel.Information;
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
@@ -47,7 +47,7 @@ public class Program
|
||||
|
||||
var host = builder.Build();
|
||||
var logFactory = host.Services.GetRequiredService<ILoggerFactory>();
|
||||
var logger = logFactory.CreateLogger("csq");
|
||||
var logger = logFactory.CreateLogger("vpk");
|
||||
Runner = new RunnerFactory(logger, host.Services.GetRequiredService<IConfiguration>());
|
||||
|
||||
CliRootCommand rootCommand = new CliRootCommand(
|
||||
|
||||
@@ -18,11 +18,11 @@ public class UpdateChecker
|
||||
var cancel = new CancellationTokenSource(3000);
|
||||
var myVer = VelopackRuntimeInfo.VelopackNugetVersion;
|
||||
var dl = new NugetDownloader(new NugetLoggingWrapper(_logger));
|
||||
var package = await dl.GetPackageMetadata("csq", (myVer.IsPrerelease || myVer.HasMetadata) ? "pre" : "latest", cancel.Token).ConfigureAwait(false);
|
||||
var package = await dl.GetPackageMetadata("vpk", (myVer.IsPrerelease || myVer.HasMetadata) ? "pre" : "latest", cancel.Token).ConfigureAwait(false);
|
||||
if (package.Identity.Version > myVer)
|
||||
_logger.Warn($"There is a newer version of csq available ({package.Identity.Version})");
|
||||
_logger.Warn($"There is a newer version of vpk available ({package.Identity.Version})");
|
||||
else
|
||||
_logger.Debug($"csq is up to date (latest online = {package.Identity.Version})");
|
||||
_logger.Debug($"vpk is up to date (latest online = {package.Identity.Version})");
|
||||
} catch (Exception ex) {
|
||||
_logger.Debug(ex, "Failed to check for updates.");
|
||||
}
|
||||
|
||||
@@ -186,8 +186,8 @@ namespace Velopack
|
||||
|
||||
// some initial setup/state
|
||||
var myVersion = locator.CurrentlyInstalledVersion;
|
||||
var firstrun = !String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("CLOWD_Velopack_FIRSTRUN"));
|
||||
var restarted = !String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("CLOWD_Velopack_RESTART"));
|
||||
var firstrun = !String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("VELOPACK_FIRSTRUN"));
|
||||
var restarted = !String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("VELOPACK_RESTART"));
|
||||
var localPackages = locator.GetLocalPackages();
|
||||
var latestLocal = locator.GetLatestLocalFullPackage();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user