<Project Sdk="Microsoft.NET.Sdk">
<TargetFramework>net9.0</TargetFramework>
<OutputType>WinExe</OutputType>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<Product>Invoice Generator</Product>
<Company>Uncharted Limbo Collective</Company>
<!-- Executable app host (required for single-file and macOS .app) -->
<UseAppHost>true</UseAppHost>
<!-- Single-file + self-contained by default (scoped per RID below if needed) -->
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<!-- Optional size/perf knobs -->
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
<IncludeNativeLibrariesForSelfExtract>false</IncludeNativeLibrariesForSelfExtract>
<IncludeAllContentForSelfExtract>false</IncludeAllContentForSelfExtract>
<!-- If trimming causes reflection issues, remove these two lines -->
<!-- <PublishTrimmed>true</PublishTrimmed>
<TrimMode>partial</TrimMode> -->
<!-- Windows exe icon -->
<ApplicationIcon>Assets/app.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<!-- macOS bundle metadata -->
<CFBundleIdentifier>com.ulc.InvoiceGenerator</CFBundleIdentifier>
<CFBundleName>Invoice Generator</CFBundleName>
<CFBundleDisplayName>Invoice Generator</CFBundleDisplayName>
<CFBundleShortVersionString>2.0.0</CFBundleShortVersionString>
<CFBundleVersion>200</CFBundleVersion>
<!-- Path to your .icns -->
<MacIconPath>Assets/AppIcon.icns</MacIconPath>
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.8" />
<PackageReference Include="Avalonia.Desktop" Version="11.3.8" />
<!-- Remove diagnostics in Release -->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Include="Material.Avalonia" Version="3.13.3-nightly.0.2" />
<PackageReference Include="Material.Avalonia.DataGrid" Version="3.13.3-nightly.0.2" />
<PackageReference Include="Material.Icons.Avalonia" Version="3.0.0-preview3.1" />
<!-- CHANGE this to your library project path -->
<ProjectReference Include="..\YourLibrary\YourLibrary.csproj" />
<!-- ===== macOS: build a .app bundle after publish ===== -->
<Target Name="BundleMacApp"
Condition="'$(RuntimeIdentifier)' == 'osx-arm64' Or '$(RuntimeIdentifier)' == 'osx-x64'">
<AppName>$(AssemblyName)</AppName>
<PublishOut>$(PublishDir)</PublishOut>
<AppBundle>$(PublishOut)$(AppName).app</AppBundle>
<MacOSDir>$(AppBundle)/Contents/MacOS</MacOSDir>
<ResDir>$(AppBundle)/Contents/Resources</ResDir>
<Plist>$(AppBundle)/Contents/Info.plist</Plist>
<Launcher>$(PublishOut)$(AssemblyName)</Launcher> <!-- native host -->
<!-- Create bundle folders -->
<Exec Command="bash -c 'set -e
rm -rf "$(AppBundle)";
mkdir -p "$(MacOSDir)" "$(ResDir)"'" />
<!-- Copy launcher and make it executable -->
<Exec Command="bash -c 'set -e
cp "$(Launcher)" "$(MacOSDir)/$(AppName)";
chmod +x "$(MacOSDir)/$(AppName)"'" />
<!-- Copy icon if present -->
<Exec Condition="Exists('$(ProjectDir)$(MacIconPath)')"
Command="bash -c 'cp "$(ProjectDir)$(MacIconPath)" "$(ResDir)/AppIcon.icns"'" />
<!-- Write Info.plist -->
<Exec Command="bash -c 'cat >"$(Plist)" <<PLIST
<?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">
<key>CFBundleIdentifier</key><string>$(CFBundleIdentifier)</string>
<key>CFBundleName</key><string>$(CFBundleName)</string>
<key>CFBundleDisplayName</key><string>$(CFBundleDisplayName)</string>
<key>CFBundleExecutable</key><string>$(AppName)</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleShortVersionString</key><string>$(CFBundleShortVersionString)</string>
<key>CFBundleVersion</key><string>$(CFBundleVersion)</string>
<key>LSMinimumSystemVersion</key><string>11.0</string>
<key>LSApplicationCategoryType</key><string>public.app-category.productivity</string>
<key>NSHighResolutionCapable</key><true/>
<key>NSPrincipalClass</key><string>NSApplication</string>
<key>CFBundleIconFile</key><string>AppIcon</string>
<!-- Optional: sign if SIGN_IDENTITY is provided -->
<Exec Condition="'$(SIGN_IDENTITY)' != ''"
Command='bash -c "codesign --force --deep --options runtime --sign "$(SIGN_IDENTITY)" "$(AppBundle)""' />
<!-- Optional: DMG if CREATE_DMG=true -->
<Exec Condition="'$(CREATE_DMG)' == 'true'"
Command='bash -c "hdiutil create -fs HFS+ -srcfolder "$(AppBundle)" -volname "$(AppName)" "$(PublishOut)$(AppName).dmg""' />