Make icon an optional parameter on linux/osx

This commit is contained in:
Caelan Sayler
2024-03-10 13:03:59 +00:00
parent 26830b5aa9
commit 7f302fccbf
14 changed files with 25 additions and 11 deletions

BIN
artwork/DefaultApp.icns Normal file

Binary file not shown.

BIN
artwork/DefaultApp_64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -13,7 +13,6 @@ fi
BUILD_VERSION="$1" BUILD_VERSION="$1"
RELEASE_DIR="$SCRIPT_DIR/releases" RELEASE_DIR="$SCRIPT_DIR/releases"
PUBLISH_DIR="$SCRIPT_DIR/publish" PUBLISH_DIR="$SCRIPT_DIR/publish"
ICON_PATH="$SCRIPT_DIR/Velopack.png"
echo "" echo ""
echo "Compiling AvaloniaCrossPlat with dotnet..." echo "Compiling AvaloniaCrossPlat with dotnet..."
@@ -21,4 +20,4 @@ dotnet publish -c Release --self-contained -r linux-x64 -o "$PUBLISH_DIR"
echo "" echo ""
echo "Building Velopack Release v$BUILD_VERSION" echo "Building Velopack Release v$BUILD_VERSION"
vpk pack -u AvaloniaCrossPlat -v $BUILD_VERSION -o "$RELEASE_DIR" -p "$PUBLISH_DIR" -i "$ICON_PATH" vpk pack -u AvaloniaCrossPlat -v $BUILD_VERSION -o "$RELEASE_DIR" -p "$PUBLISH_DIR"

View File

@@ -13,7 +13,6 @@ fi
BUILD_VERSION="$1" BUILD_VERSION="$1"
RELEASE_DIR="$SCRIPT_DIR/releases" RELEASE_DIR="$SCRIPT_DIR/releases"
PUBLISH_DIR="$SCRIPT_DIR/publish" PUBLISH_DIR="$SCRIPT_DIR/publish"
ICON_PATH="$SCRIPT_DIR/Velopack.icns"
echo "" echo ""
echo "Compiling AvaloniaCrossPlat with dotnet..." echo "Compiling AvaloniaCrossPlat with dotnet..."
@@ -21,4 +20,4 @@ dotnet publish -c Release --self-contained -r osx-x64 -o "$PUBLISH_DIR"
echo "" echo ""
echo "Building Velopack Release v$BUILD_VERSION" echo "Building Velopack Release v$BUILD_VERSION"
vpk pack -u AvaloniaCrossPlat -v $BUILD_VERSION -o "$RELEASE_DIR" -p "$PUBLISH_DIR" -i "$ICON_PATH" vpk pack -u AvaloniaCrossPlat -v $BUILD_VERSION -o "$RELEASE_DIR" -p "$PUBLISH_DIR"

View File

@@ -54,7 +54,8 @@ Categories=Development;
// copy existing app files // copy existing app files
CopyFiles(new DirectoryInfo(packDir), bin, progress, true); CopyFiles(new DirectoryInfo(packDir), bin, progress, true);
// app icon // app icon
File.Copy(Options.Icon, Path.Combine(dir.FullName, Options.PackId + Path.GetExtension(Options.Icon)), true); var icon = Options.Icon ?? HelperFile.GetDefaultAppIcon();
File.Copy(icon, Path.Combine(dir.FullName, Options.PackId + Path.GetExtension(icon)), true);
} }
// velopack required files // velopack required files

View File

@@ -25,7 +25,7 @@ public class OsxBundleCommandRunner : ICommand<OsxBundleOptions>
public string Bundle(OsxBundleOptions options) public string Bundle(OsxBundleOptions options)
{ {
var icon = options.Icon; var icon = options.Icon ?? HelperFile.GetDefaultAppIcon();
var packId = options.PackId; var packId = options.PackId;
var packDirectory = options.PackDirectory; var packDirectory = options.PackDirectory;
var packVersion = options.PackVersion; var packVersion = options.PackVersion;

View File

@@ -6,4 +6,5 @@ public interface IPackOptions : INugetPackCommand, IPlatformOptions
DeltaMode DeltaMode { get; } DeltaMode DeltaMode { get; }
string EntryExecutableName { get; } string EntryExecutableName { get; }
bool IncludePdb { get; } bool IncludePdb { get; }
string Icon { get; }
} }

View File

@@ -54,6 +54,21 @@ public static class HelperFile
[SupportedOSPlatform("windows")] [SupportedOSPlatform("windows")]
public static string RceditPath => FindHelperFile("rcedit.exe"); public static string RceditPath => FindHelperFile("rcedit.exe");
public static string GetDefaultAppIcon(RuntimeOs? os = null)
{
var _os = os ?? VelopackRuntimeInfo.SystemOs;
switch (_os) {
case RuntimeOs.Windows:
return null;
case RuntimeOs.Linux:
return FindHelperFile("DefaultApp_64.png");
case RuntimeOs.OSX:
return FindHelperFile("DefaultApp.icns");
default:
throw new PlatformNotSupportedException("Default Icon is not available for this platform.");
}
}
private static List<string> _searchPaths = new List<string>(); private static List<string> _searchPaths = new List<string>();
static HelperFile() static HelperFile()
@@ -61,6 +76,7 @@ public static class HelperFile
#if DEBUG #if DEBUG
AddSearchPath(AppContext.BaseDirectory, "..", "..", "..", "src", "Rust", "target", "debug"); AddSearchPath(AppContext.BaseDirectory, "..", "..", "..", "src", "Rust", "target", "debug");
AddSearchPath(AppContext.BaseDirectory, "..", "..", "..", "vendor"); AddSearchPath(AppContext.BaseDirectory, "..", "..", "..", "vendor");
AddSearchPath(AppContext.BaseDirectory, "..", "..", "..", "artwork");
#else #else
AddSearchPath(AppContext.BaseDirectory, "..", "..", "..", "vendor"); AddSearchPath(AppContext.BaseDirectory, "..", "..", "..", "vendor");
#endif #endif

View File

@@ -92,9 +92,8 @@ public class LinuxPackCommand : PlatformCommand
.SetArgumentHelpName("DIR") .SetArgumentHelpName("DIR")
.MustNotBeEmpty(); .MustNotBeEmpty();
this.AreMutuallyExclusive(packDir, appDir);
this.AtLeastOneRequired(packDir, appDir); this.AtLeastOneRequired(packDir, appDir);
this.AreMutuallyExclusive(packDir, appDir);
this.AreMutuallyExclusive(icon, appDir); this.AreMutuallyExclusive(icon, appDir);
this.AtLeastOneRequired(icon, appDir);
} }
} }

View File

@@ -62,7 +62,6 @@ public class OsxBundleCommand : PlatformCommand
.SetDescription("Path to the .icns file for this bundle.") .SetDescription("Path to the .icns file for this bundle.")
.SetArgumentHelpName("PATH") .SetArgumentHelpName("PATH")
.MustExist() .MustExist()
.SetRequired()
.RequiresExtension(".icns"); .RequiresExtension(".icns");
var bundleId = AddOption<string>((v) => BundleId = v, "--bundleId") var bundleId = AddOption<string>((v) => BundleId = v, "--bundleId")

View File

@@ -34,6 +34,8 @@
<None Include="..\..\vendor\zstd.exe" Pack="true" PackagePath="vendor" /> <None Include="..\..\vendor\zstd.exe" Pack="true" PackagePath="vendor" />
<None Include="..\..\vendor\signtool.exe" Pack="true" PackagePath="vendor" /> <None Include="..\..\vendor\signtool.exe" Pack="true" PackagePath="vendor" />
<None Include="..\..\Velopack.entitlements" Pack="true" PackagePath="vendor" /> <None Include="..\..\Velopack.entitlements" Pack="true" PackagePath="vendor" />
<None Include="..\..\artwork\DefaultApp.icns" Pack="true" PackagePath="vendor" />
<None Include="..\..\artwork\DefaultApp_64.png" Pack="true" PackagePath="vendor" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -51,7 +51,6 @@ public static class TestApp
EntryExecutableName = "TestApp", EntryExecutableName = "TestApp",
ReleaseDir = new DirectoryInfo(releaseDir), ReleaseDir = new DirectoryInfo(releaseDir),
PackId = id, PackId = id,
Icon = Path.Combine(PathHelper.GetProjectDir(), "samples", "AvaloniaCrossPlat", "Velopack.icns"),
TargetRuntime = RID.Parse(VelopackRuntimeInfo.SystemOs.GetOsShortName()), TargetRuntime = RID.Parse(VelopackRuntimeInfo.SystemOs.GetOsShortName()),
PackVersion = version, PackVersion = version,
PackDirectory = Path.Combine(projDir, "publish"), PackDirectory = Path.Combine(projDir, "publish"),
@@ -65,7 +64,6 @@ public static class TestApp
EntryExecutableName = "TestApp", EntryExecutableName = "TestApp",
ReleaseDir = new DirectoryInfo(releaseDir), ReleaseDir = new DirectoryInfo(releaseDir),
PackId = id, PackId = id,
Icon = Path.Combine(PathHelper.GetProjectDir(), "samples", "AvaloniaCrossPlat", "Velopack.png"),
TargetRuntime = RID.Parse(VelopackRuntimeInfo.SystemOs.GetOsShortName()), TargetRuntime = RID.Parse(VelopackRuntimeInfo.SystemOs.GetOsShortName()),
PackVersion = version, PackVersion = version,
PackDirectory = Path.Combine(projDir, "publish"), PackDirectory = Path.Combine(projDir, "publish"),