Skip to content

Commit

Permalink
refactor(build): uniformize dotnet publish properties
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Jan 9, 2025
1 parent 37dd971 commit e6bee3a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
16 changes: 5 additions & 11 deletions SubRenamer/SubRenamer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<TargetFramework>net8.0</TargetFramework>
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
<Nullable>enable</Nullable>
<TrimMode>copyused</TrimMode>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<!--Public AOT-->
<!-- Public AOT -->
<PublishAot>true</PublishAot>
<TrimMode>link</TrimMode>
<PublishTrimmed>true</PublishTrimmed>
<SelfContained>true</SelfContained>
<InvariantGlobalization>true</InvariantGlobalization>
<StripSymbols>true</StripSymbols>
<NoWarn>IL2057;IL2026;IL2104;IL3053</NoWarn>
Expand All @@ -33,14 +34,7 @@
<LinkerArg Include="-mmacosx-version-min=11.0" />
</ItemGroup>

<ItemGroup>
<!--This helps with theme dll-s trimming.
If you will publish your application in self-contained mode with p:PublishTrimmed=true and it will use Fluent theme Default theme will be trimmed from the output and vice versa.
https://github.com/AvaloniaUI/Avalonia/issues/5593 -->
<TrimmableAssembly Include="Avalonia.Themes.Fluent" />
<TrimmableAssembly Include="Avalonia.Themes.Default" />
</ItemGroup>

<!-- https://github.com/AvaloniaUI/Avalonia/issues/9503 -->
<ItemGroup Condition="$(RuntimeIdentifier.StartsWith('win')) And '$(ENABLE_NATIVE_LIBS)' == 'true'">
<DirectPInvoke Include="libHarfBuzzSharp" />
<NativeLibrary Include="native\libHarfBuzzSharp.lib" Condition="$(RuntimeIdentifier.StartsWith('win'))" />
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-linux.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

mkdir -p dist/SubRenamer
dotnet publish ../SubRenamer/SubRenamer.csproj -c Release -r linux-x64 -o dist/SubRenamer -p:PublishAot=true -p:PublishTrimmed=true -p:TrimMode=link --self-contained
dotnet publish ../SubRenamer/SubRenamer.csproj -c Release -r linux-x64 -o dist/SubRenamer

if command -v upx &> /dev/null; then
upx -fq dist/SubRenamer/SubRenamer dist/SubRenamer/*.so
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ cp resources/App.plist dist/SubRenamer.app/Contents/Info.plist
cp resources/App.icns dist/SubRenamer.app/Contents/Resources/App.icns

mkdir -p dist/SubRenamer.app/Contents/MacOS
dotnet publish $CS_PROJ -c Release -r osx-arm64 -o dist/SubRenamer.app/Contents/MacOS -p:PublishAot=true -p:PublishTrimmed=true -p:TrimMode=link --self-contained
dotnet publish $CS_PROJ -c Release -r osx-arm64 -o dist/SubRenamer.app/Contents/MacOS
cd dist
zip SubRenamer_macos_arm64.zip -9 -r SubRenamer.app -x "*/*\.dsym/*"
cd ..

rm -rf dist/SubRenamer.app/Contents/MacOS

mkdir -p dist/SubRenamer.app/Contents/MacOS
dotnet publish $CS_PROJ -c Release -r osx-x64 -o dist/SubRenamer.app/Contents/MacOS -p:PublishAot=true -p:PublishTrimmed=true -p:TrimMode=link --self-contained
dotnet publish $CS_PROJ -c Release -r osx-x64 -o dist/SubRenamer.app/Contents/MacOS
cd dist
zip SubRenamer_macos_amd64.zip -9 -r SubRenamer.app -x "*/*\.dsym/*"
cd ..
2 changes: 1 addition & 1 deletion scripts/build-win.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (Test-Path dist\SubRenamer_windows_amd64.zip) {
Remove-Item dist\SubRenamer_windows_amd64.zip -Force
}

dotnet publish ..\SubRenamer\SubRenamer.csproj -c Release -r win-x64 -o dist\SubRenamer -p:PublishAot=true -p:PublishTrimmed=true -p:TrimMode=link --self-contained
dotnet publish ..\SubRenamer\SubRenamer.csproj -c Release -r win-x64 -o dist\SubRenamer

$files = Get-ChildItem -Path dist\SubRenamer
$files | Where-Object { $_.Name -ne "SubRenamer.exe" } | Remove-Item -Force
Expand Down

0 comments on commit e6bee3a

Please sign in to comment.