Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# MacOS Finder files
*.DS_Store
.DS_Store?

# User-specific files
*.rsuser
*.suo
Expand Down
8 changes: 8 additions & 0 deletions macbuild/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This script builds the app, codesigns it, notarizes it, packages it into a disk image for intuitive installation, and notarizes that dmg.

To properly build and codesign for MacOS, this script needs to be run by someone with an Apple Developer Program account.
As this costs $99 a year to obtain, builds are currently made by @gdmagana.
The Stardrop.csproj also must be replaced in the original project so that both architectures can be targeted.

usage:
`./build-mac --arch osx-arm64` (leave blank to build both)
180 changes: 180 additions & 0 deletions macbuild/Stardrop.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>1.2.1</Version>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
<RuntimeIdentifier>osx-x64;osx-arm64</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath></OutputPath>
<!-- <PlatformTarget>x64</PlatformTarget> -->
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<!-- <PlatformTarget>x64</PlatformTarget> -->
</PropertyGroup>
<ItemGroup>
<AvaloniaResource Include="Assets\**" />
<Content Include="Themes\*" CopyToOutputDirectory="PreserveNewest" />
<Content Include="i18n\*" CopyToOutputDirectory="PreserveNewest" />
<None Remove=".gitignore" />
<None Remove="Assets\icon.ico" />
<None Remove="Assets\Info.plist" />
<None Remove="Assets\smapi.png" />
<None Remove="Assets\Stardrop.icns" />
<None Remove="Assets\Stardrop.sh" />
<None Remove="Themes\Dark.xaml" />
<None Remove="Themes\Light.xaml" />
<None Remove="Themes\Solarized-Lite.xaml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.17" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="0.10.17" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.17" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.17" />
<PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="0.10.17" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.17" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Json.More.Net" Version="2.0.1" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="Projektanker.Icons.Avalonia" Version="5.13.0" />
<PackageReference Include="Projektanker.Icons.Avalonia.MaterialDesign" Version="5.13.0" />
<PackageReference Include="semver" Version="2.3.0" />
<PackageReference Include="SharpCompress" Version="0.32.1" />
</ItemGroup>
<ItemGroup>
<Compile Update="Views\FlexibleOptionWindow.axaml.cs">
<DependentUpon>FlexibleOptionWindow.axaml</DependentUpon>
</Compile>
<Compile Update="Views\NexusInfo.axaml.cs">
<DependentUpon>NexusInfo.axaml</DependentUpon>
</Compile>
<Compile Update="Views\ProfileNaming.axaml.cs">
<DependentUpon>ProfileNaming.axaml</DependentUpon>
</Compile>
<Compile Update="Views\ProfileEditor.axaml.cs">
<DependentUpon>ProfileEditor.axaml</DependentUpon>
</Compile>
<Compile Update="Views\WarningWindow.axaml.cs">
<DependentUpon>WarningWindow.axaml</DependentUpon>
</Compile>
<Compile Update="Views\DownloadPanel.axaml.cs">
<DependentUpon>DownloadPanel.axaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Update="Themes\Light.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Content>
<Content Update="Themes\Solarized-Lite.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Content>
<Content Update="Themes\Dark.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Content>
<Content Update="Themes\Stardrop.xaml">
<Generator>MSBuild:Compile</Generator>
</Content>
</ItemGroup>

<ItemGroup Condition="$(Configuration)=='Release' And $(RuntimeIdentifier)=='linux-x64'">
<WSL Include="wsl" Condition="$([MSBuild]::IsOSPlatform('Windows'))" />
<BashScript Include="$(ProjectDir)\Assets\Stardrop.sh" />
<RenameExecutableLinux Include="$(PublishDir)\Stardrop" />
<RenameDatabaseLinux Include="$(PublishDir)\Stardrop.pdb" />
<ZipName Include="Stardrop-linux-x64.zip" />
</ItemGroup>

<Target Name="FolderProfile - Linux" AfterTargets="Publish" Condition="$(Configuration)=='Release' And $(RuntimeIdentifier)=='linux-x64'">
<Delete Files="$(PublishDir)/$(ZipName)" />

<Copy SourceFiles="@(RenameExecutableLinux)" DestinationFiles="@(RenameExecutableLinux-&gt;Replace('Stardrop','Internal'))" />
<Copy SourceFiles="@(RenameDatabaseLinux)" DestinationFiles="@(RenameDatabaseLinux-&gt;Replace('Stardrop','Internal'))" />
<Delete Files="@(RenameExecutableLinux);@(RenameDatabaseLinux)" />

<Copy SourceFiles="@(BashScript)" DestinationFolder="$(PublishDir)" />

<Exec Command="@(WSL) mkdir Stardrop" WorkingDirectory="$(PublishDir)" />

<Move SourceFiles="$(PublishDir)/Internal;$(PublishDir)/Internal.pdb;$(PublishDir)/Stardrop.sh" DestinationFolder="$(PublishDir)/Stardrop" />
<Exec Command="@(WSL) mv Themes Stardrop" WorkingDirectory="$(PublishDir)" />
<Exec Command="@(WSL) mv i18n Stardrop" WorkingDirectory="$(PublishDir)" />

<Exec Command="@(WSL) chmod 755 Stardrop" WorkingDirectory="$(PublishDir)" />
<Exec Command="@(WSL) chmod +x Stardrop.sh" WorkingDirectory="$(PublishDir)/Stardrop" />
<Exec Command="@(WSL) chmod 644 Internal" WorkingDirectory="$(PublishDir)/Stardrop" />
<Exec Command="@(WSL) chmod 644 Internal.pdb" WorkingDirectory="$(PublishDir)/Stardrop" />
<Exec Command="@(WSL) zip -r @(ZipName) Stardrop" WorkingDirectory="$(PublishDir)" />

<RemoveDir Directories="$(PublishDir)/Stardrop" />
</Target>

<!-- <ItemGroup Condition="$(Configuration)=='Release' And $(RuntimeIdentifier)=='osx-x64'">
<WSL Include="wsl" />
<TempFolderPath Include="Stardrop_Temp" />
<AppFolderPath Include="$(ProjectDir)Assets/Stardrop.app" />
<MacOSFolderPath Include="$(ProjectDir)Assets/Stardrop.app/Contents/MacOS" />
<InfoPath Include="$(ProjectDir)/Assets/Info.plist" />
<IconPath Include="$(ProjectDir)/Assets/Stardrop.icns" />
<ZipName Include="Stardrop-osx-x64.zip" />
</ItemGroup> -->

<!-- <ItemGroup Condition="$(Configuration)=='Release' And ($(RuntimeIdentifier)=='osx-x64' Or $(RuntimeIdentifier)=='osx-arm64')">
<WSL Include="wsl" />
<TempFolderPath Include="Stardrop_Temp" />
<AppFolderPath Include="$(ProjectDir)Assets/Stardrop.app" />
<MacOSFolderPath Include="$(ProjectDir)Assets/Stardrop.app/Contents/MacOS" />
<InfoPath Include="$(ProjectDir)/Assets/Info.plist" />
<IconPath Include="$(ProjectDir)/Assets/Stardrop.icns" />
<ZipName Include="Stardrop-$(RuntimeIdentifier).zip" />
</ItemGroup> -->

<!-- <Target Name="FolderProfile - MacOS" AfterTargets="Publish" Condition="$(Configuration)=='Release' And ($(RuntimeIdentifier)=='osx-x64' Or $(RuntimeIdentifier)=='osx-arm64')"> -->
<!-- <Exec Command="rm -f @(ZipName)" WorkingDirectory="$(PublishDir)" />
<Exec Command="rm -rf Stardrop.app" WorkingDirectory="$(PublishDir)" />

<Exec Command="cp -R @(AppFolderPath) Stardrop.app" WorkingDirectory="$(PublishDir)" />

<Exec Command="mv Themes @(MacOSFolderPath)/Themes" WorkingDirectory="$(PublishDir)" />
<Exec Command="mv i18n @(MacOSFolderPath)/i18n" WorkingDirectory="$(PublishDir)" />
<Exec Command="mv *.dylib @(MacOSFolderPath)" WorkingDirectory="$(PublishDir)" />
<Exec Command="mv Stardrop @(MacOSFolderPath)" WorkingDirectory="$(PublishDir)" />
<Exec Command="mv Stardrop.pdb @(MacOSFolderPath)" WorkingDirectory="$(PublishDir)" />

<Copy SourceFiles="@(InfoPath)" DestinationFolder="$(PublishDir)/Stardrop.app/Contents" />
<Copy SourceFiles="@(IconPath)" DestinationFolder="$(PublishDir)/Stardrop.app/Contents/Resources" />

<Exec Command="chmod +x Stardrop" WorkingDirectory="$(PublishDir)@(MacOSFolderPath)" />

<Exec Command="zip -r @(ZipName) Stardrop.app" WorkingDirectory="$(PublishDir)" />
<Exec Command="rm -rf Stardrop.app" WorkingDirectory="$(PublishDir)" /> -->
<!-- </Target> -->


<ItemGroup Condition="$(Configuration)=='Release' And $(RuntimeIdentifier)=='win-x64'">
<WSL Include="wsl" />
<TempFolderPath Include="Stardrop_Temp" />
<ZipName Include="Stardrop-win-x64.zip" />
</ItemGroup>

<Target Name="FolderProfile - Windows" AfterTargets="Publish" Condition="$(Configuration)=='Release' And $(RuntimeIdentifier)=='win-x64'">
<Exec Command="del @(ZipName) 2&gt;nul" WorkingDirectory="$(PublishDir)" />

<Exec Command="@(WSL) mkdir @(TempFolderPath)" WorkingDirectory="$(PublishDir)" />

<Exec Command="@(WSL) mv Themes @(TempFolderPath)" WorkingDirectory="$(PublishDir)" />
<Exec Command="@(WSL) mv i18n @(TempFolderPath)" WorkingDirectory="$(PublishDir)" />
<Exec Command="@(WSL) mv Stardrop.exe Stardrop.pdb @(TempFolderPath)" WorkingDirectory="$(PublishDir)" />

<Exec Command="ren @(TempFolderPath) Stardrop" WorkingDirectory="$(PublishDir)" />
<Exec Command="@(WSL) zip -r @(ZipName) Stardrop" WorkingDirectory="$(PublishDir)" />
<Exec Command="rmdir Stardrop /S /Q" WorkingDirectory="$(PublishDir)" />
</Target>
</Project>
Binary file added macbuild/assets/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions macbuild/assets/ents.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.automation.apple-events</key>
<true/>
</dict>
</plist>
130 changes: 130 additions & 0 deletions macbuild/build-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/bin/bash

APP_NAME="Stardrop"
HOME="/Users/gdmagana"
PROJECT_DIR="$HOME/Developer/Github/Stardrop/Stardrop"
OUTPUT_DIR="$HOME/Developer/Github/Stardrop/releases"
ASSETS_DIR="$PROJECT_DIR/Assets"
MAC_ASSETS_DIR="assets"
ENTITLEMENTS="$MAC_ASSETS_DIR/ents.entitlements"
SIGNING_IDENTITY="Developer ID Application: Gabriel Magaña (Z4D7MUNZ97)"
DMG_BACKGROUND="$MAC_ASSETS_DIR/background.png"

# Architectures to build for
DEFAULT_ARCHS=("osx-x64" "osx-arm64")
ARCHS=()

# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--arch)
if [[ -z "$2" || "$2" == --* ]]; then
echo "Error: --arch requires an architecture value"
exit 1
fi
ARCHS+=("$2")
shift 2
;;
--arch=*)
arch_value="${1#*=}"
if [[ -z "$arch_value" ]]; then
echo "Error: --arch= requires an architecture value"
exit 1
fi
ARCHS+=("$arch_value")
shift
;;
-h|--help)
echo "Usage: $0 [--arch architecture]"
echo " --arch architecture Build for specific architecture (can be specified multiple times)"
echo " Default: osx-x64 osx-arm64"
exit 0
;;
*)
echo "Unknown parameter: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done

# If no architectures specified, use defaults
if [ ${#ARCHS[@]} -eq 0 ]; then
ARCHS=("${DEFAULT_ARCHS[@]}")
fi

# Ensure output directory exists
mkdir -p "$OUTPUT_DIR"

for ARCH in "${ARCHS[@]}"; do
echo "[INFO] Building for $ARCH..."
mkdir -p "$OUTPUT_DIR/$ARCH"

# Step 1: Build the project
# dotnet publish "$PROJECT_DIR/Stardrop.csproj" -c Release -r $ARCH --self-contained || exit 1
dotnet publish "$PROJECT_DIR/Stardrop.csproj" -r $ARCH -c Release /p:PublishSingleFile=true \
/p:IncludeAllContentForSelfExtract=true /p:IncludeNativeLibrariesForSelfExtract=true \
/p:EnableCompressionInSingleFile=true /p:PublishReadyToRun=true \
-p:UseAppHost=true --self-contained true || exit 1
# Check if the build was successful
if [ $? -ne 0 ]; then
echo "[ERROR] Build failed for $ARCH"
exit 1
fi
echo "[INFO] Build successful for $ARCH"

# Step 2: Create the .app bundle
BUILD_DIR="$PROJECT_DIR/bin/Release/$ARCH/publish"
APP_BUNDLE="$OUTPUT_DIR/$ARCH/$APP_NAME.app"
rm -rf "$APP_BUNDLE"
mkdir -p "$APP_BUNDLE/Contents/MacOS"
mkdir -p "$APP_BUNDLE/Contents/Resources"

# Copy executable and resources
cp "$BUILD_DIR/$APP_NAME" "$APP_BUNDLE/Contents/MacOS/"
cp "$BUILD_DIR/"*.dylib "$APP_BUNDLE/Contents/MacOS/"
cp -R "$BUILD_DIR/Themes" "$APP_BUNDLE/Contents/MacOS/"
cp -R "$BUILD_DIR/i18n" "$APP_BUNDLE/Contents/MacOS/"
cp "$ASSETS_DIR/Info.plist" "$APP_BUNDLE/Contents/"
cp "$ASSETS_DIR/Stardrop.icns" "$APP_BUNDLE/Contents/Resources/"

# Step 3: Sign the .app bundle
echo "[INFO] Signing the .app bundle for $ARCH..."
find "$APP_BUNDLE/Contents/MacOS" -type f | while read -r fname; do
codesign --force --timestamp --options=runtime --entitlements "$ENTITLEMENTS" --sign "$SIGNING_IDENTITY" "$fname"
done
codesign --force --timestamp --options=runtime --entitlements "$ENTITLEMENTS" --sign "$SIGNING_IDENTITY" "$APP_BUNDLE"

# Step 4: Notarize the .app bundle
echo "[INFO] Notarizing the .app bundle for $ARCH..."
ZIP_FILE="$OUTPUT_DIR/$ARCH/$APP_NAME.zip"
ditto -c -k --sequesterRsrc --keepParent "$APP_BUNDLE" "$ZIP_FILE"
xcrun notarytool submit "$ZIP_FILE" --wait --keychain-profile Stardrop || exit 1
xcrun stapler staple "$APP_BUNDLE"
# Cleanup
rm "$ZIP_FILE"

# Step 5: Create a DMG file
echo "[INFO] Creating a DMG file for $ARCH..."
DMG_FILE="$OUTPUT_DIR/$ARCH/$APP_NAME.dmg"
# Clean up any old temporary DMG files
rm -f "$OUTPUT_DIR"/"$ARCH"/rw.*.dmg
create-dmg \
--icon-size 128 \
--volname "$APP_NAME" \
--text-size 16 \
--icon "$APP_NAME.app" 200 150 \
--app-drop-link 450 150 \
--window-pos 200 200 \
--window-size 650 376 \
--background "$DMG_BACKGROUND" \
--disk-image-size 150 \
"$DMG_FILE" "$OUTPUT_DIR/$ARCH" \

# Step 6: Notarize the DMG file
echo "[INFO] Notarizing the DMG file for $ARCH..."
xcrun notarytool submit "$DMG_FILE" --wait --keychain-profile Stardrop || exit 1
xcrun stapler staple "$DMG_FILE"
done

echo "[INFO] Build and packaging complete. Output: $OUTPUT_DIR"