mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
This re-implements the msi installer that was present inside of Clowd.Squirrel. This is hidden behind some hidden options.
65 lines
2.1 KiB
C#
65 lines
2.1 KiB
C#
using NuGet.Versioning;
|
|
|
|
namespace Velopack.Core;
|
|
|
|
public static class DefaultName
|
|
{
|
|
public static string GetSuggestedReleaseName(string id, string version, string channel, bool delta, RuntimeOs os)
|
|
{
|
|
var suffix = GetUniqueAssetSuffix(channel);
|
|
version = SemanticVersion.Parse(version).ToNormalizedString();
|
|
if (os == RuntimeOs.Windows && channel == GetDefaultChannel(RuntimeOs.Windows)) {
|
|
return $"{id}-{version}{(delta ? "-delta" : "-full")}.nupkg";
|
|
}
|
|
|
|
return $"{id}-{version}{suffix}{(delta ? "-delta" : "-full")}.nupkg";
|
|
}
|
|
|
|
public static string GetSuggestedPortableName(string id, string channel, RuntimeOs os)
|
|
{
|
|
var suffix = GetUniqueAssetSuffix(channel);
|
|
if (os == RuntimeOs.Linux) {
|
|
if (channel == GetDefaultChannel(RuntimeOs.Linux)) {
|
|
return $"{id}.AppImage";
|
|
} else {
|
|
return $"{id}{suffix}.AppImage";
|
|
}
|
|
} else {
|
|
return $"{id}{suffix}-Portable.zip";
|
|
}
|
|
}
|
|
|
|
public static string GetSuggestedSetupName(string id, string channel, RuntimeOs os)
|
|
{
|
|
var suffix = GetUniqueAssetSuffix(channel);
|
|
if (os == RuntimeOs.Windows)
|
|
return $"{id}{suffix}-Setup.exe";
|
|
else if (os == RuntimeOs.OSX)
|
|
return $"{id}{suffix}-Setup.pkg";
|
|
else
|
|
throw new PlatformNotSupportedException("Platform not supported.");
|
|
}
|
|
|
|
|
|
public static string GetSuggestedMsiName(string id, string channel, RuntimeOs os)
|
|
{
|
|
var suffix = GetUniqueAssetSuffix(channel);
|
|
if (os == RuntimeOs.Windows)
|
|
return $"{id}{suffix}-DeploymentTool.msi";
|
|
else
|
|
throw new PlatformNotSupportedException("Platform not supported.");
|
|
}
|
|
|
|
private static string GetUniqueAssetSuffix(string channel)
|
|
{
|
|
return "-" + channel;
|
|
}
|
|
|
|
public static string GetDefaultChannel(RuntimeOs os)
|
|
{
|
|
if (os == RuntimeOs.Windows) return "win";
|
|
if (os == RuntimeOs.OSX) return "osx";
|
|
if (os == RuntimeOs.Linux) return "linux";
|
|
throw new NotSupportedException("Unsupported OS: " + os);
|
|
}
|
|
} |