Skip to content

Commit

Permalink
Add and deprecate target frameworks (#90)
Browse files Browse the repository at this point in the history
* Add and deprecate target frameworks

* Update workflows and NuGet packages

* Update dockerfiles

* Remove compatibility

* Update NuGet packages

* Workaround for missing PNG compression in SkiaSharp 3.x

* Add strong names and fix unit test assets

* Remove MonoConsole
  • Loading branch information
sungaila authored Oct 18, 2024
1 parent 44115ff commit d61f1d1
Show file tree
Hide file tree
Showing 106 changed files with 579 additions and 3,731 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body:
attributes:
label: PDFtoImage version
description: Which version of PDFtoImage is affected?
value: 4.1.1
value: 5.0.0
validations:
required: true
- type: dropdown
Expand Down
72 changes: 24 additions & 48 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ jobs:
with:
dotnet-version: |
6.x
7.x
8.x
9.x
dotnet-quality: 'ga'
- name: Setup .NET workload maui-android
run: dotnet workload install maui-android
- name: Setup .NET workload maui-ios
Expand Down Expand Up @@ -117,51 +118,26 @@ jobs:
if-no-files-found: error
retention-days: 1
compression-level: 9
- name: Publish test project MonoConsole
uses: actions/upload-artifact@main
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true
with:
name: MonoConsole
path: src/FrameworkTests/MonoConsole/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}
if-no-files-found: error
retention-days: 1
test:
name: Test (${{ matrix.os }})
needs: build
strategy:
fail-fast: false
matrix:
os: [windows-2019, windows-2022, ubuntu-20.04, ubuntu-22.04, macos-12, macos-13, macos-14]
os: [windows-2019, windows-2022, ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-12, macos-13, macos-14, macos-15]
runs-on: ${{ matrix.os }}
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true
steps:
- name: Setup Mono
if: runner.os == 'Windows'
run: choco install mono -y && Add-Content $env:GITHUB_PATH "C:\Program Files\Mono\bin"
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: |
6.x
7.x
8.x
- name: Download test project MonoConsole
if: success() || failure()
uses: actions/download-artifact@main
with:
name: MonoConsole
path: MonoConsole
- name: Mono (.NET Framework 4.6.2)
if: success() || failure()
run: mono MonoConsole/net462/PDFtoImage.FrameworkTests.MonoConsole.exe
- name: Mono (.NET Framework 4.7.1)
if: success() || failure()
run: mono MonoConsole/net471/PDFtoImage.FrameworkTests.MonoConsole.exe
- name: Mono (.NET Framework 4.8.1)
if: success() || failure()
run: mono MonoConsole/net481/PDFtoImage.FrameworkTests.MonoConsole.exe
9.x
dotnet-quality: 'ga'
- name: Download test assemblies
if: success() || failure()
if: (success() || failure())
uses: actions/download-artifact@main
with:
name: Test assemblies
Expand All @@ -177,12 +153,12 @@ jobs:
- name: .NET 6
if: success() || failure()
run: dotnet test net6.0/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net6.0/SaveOutputInGeneratedFolder.runsettings' || '' }}
- name: .NET 7
if: success() || failure()
run: dotnet test net7.0/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net8.0/SaveOutputInGeneratedFolder.runsettings' || '' }}
- name: .NET 8
if: success() || failure()
run: dotnet test net8.0/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net8.0/SaveOutputInGeneratedFolder.runsettings' || '' }}
- name: .NET 9
if: success() || failure()
run: dotnet test net9.0/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net9.0/SaveOutputInGeneratedFolder.runsettings' || '' }}
- name: Upload test results
if: success() || failure()
uses: actions/upload-artifact@main
Expand Down Expand Up @@ -216,30 +192,27 @@ jobs:
src/PDFtoImage
src/FrameworkTests/AotConsole
src/Tests/Assets/SocialPreview.pdf
- name: console (alpine)
if: runner.os == 'Linux' && (success() || failure())
run: docker buildx build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/alpine.dockerfile . && docker run --rm -t console
- name: console (alpine-aot)
if: runner.os == 'Linux' && (success() || failure())
run: docker buildx build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/alpine-aot.dockerfile . && docker run --rm -t console
- name: console (ubuntu)
if: runner.os == 'Linux' && (success() || failure())
run: docker build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/ubuntu.dockerfile . && docker run --rm -t console
run: docker buildx build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/ubuntu.dockerfile . && docker run --rm -t console
- name: console (ubuntu-chiseled)
if: runner.os == 'Linux' && (success() || failure())
run: docker build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/ubuntu-chiseled.dockerfile . && docker run --rm -t console
run: docker buildx build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/ubuntu-chiseled.dockerfile . && docker run --rm -t console
- name: console (ubuntu-aot)
if: runner.os == 'Linux' && (success() || failure())
run: docker build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/ubuntu-aot.dockerfile . && docker run --rm -t console
run: docker buildx build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/ubuntu-aot.dockerfile . && docker run --rm -t console
- name: console (ubuntu-chiseled-aot)
if: runner.os == 'Linux' && (success() || failure())
run: docker build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/ubuntu-chiseled-aot.dockerfile . && docker run --rm -t console
run: docker buildx build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/ubuntu-chiseled-aot.dockerfile . && docker run --rm -t console
- name: console (windows-servercore)
if: runner.os == 'Windows' && (success() || failure())
run: xcopy /y "src\FrameworkTests\AotConsole\Dockerfiles\windows-servercore.dockerfile" . && docker build -t console -f windows-servercore.dockerfile . && docker run --rm -t console
- name: console (windows-servercore-aot)
if: false && runner.os == 'Windows' && (success() || failure())
run: xcopy /y "src\FrameworkTests\AotConsole\Dockerfiles\windows-servercore-aot.dockerfile" . && docker build -t console -f windows-servercore-aot.dockerfile . && docker run --rm -t console
- name: console (windows-nanoserver)
if: false && runner.os == 'Windows' && (success() || failure())
run: xcopy /y "src\FrameworkTests\AotConsole\Dockerfiles\windows-nanoserver.dockerfile" . && docker build -t console -f windows-nanoserver.dockerfile . && docker run --rm -t console
- name: console (windows-nanoserver-aot)
if: false && runner.os == 'Windows' && (success() || failure())
run: xcopy /y "src\FrameworkTests\AotConsole\Dockerfiles\windows-nanoserver-aot.dockerfile" . && docker build -t console -f windows-nanoserver-aot.dockerfile . && docker run --rm -t console
run: docker build -t console -f src\FrameworkTests\AotConsole\Dockerfiles\windows-servercore.dockerfile . && docker run --rm -t console
publish-test-results:
name: Publish tests results
needs: [test, docker]
Expand Down Expand Up @@ -290,10 +263,13 @@ jobs:
with:
dotnet-version: |
6.x
7.x
8.x
9.x
dotnet-quality: 'ga'
- name: Setup .NET workload maui-android
run: dotnet workload install maui-android
- name: Setup .NET workload maui-ios
run: dotnet workload install maui-ios
- name: Setup dotnet-coverage
run: dotnet tool install --global dotnet-coverage
- name: Setup JDK 17
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/githubpages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: 8.x
dotnet-version: 9.x
dotnet-quality: 'ga'
- name: Setup .NET workload maui-android
run: dotnet workload install maui-android
- name: Setup .NET workload maui-ios
Expand All @@ -40,9 +41,9 @@ jobs:
- name: Publish
run: dotnet publish src/WebConverter/WebConverter.csproj -c Release -p:PublishProfile=src/WebConverter/Properties/PublishProfiles/PublishSite.pubxml -p:VersionSuffix=ci --no-restore
- name: Create .nojekyll file
run: touch src/WebConverter/bin/Release/net8.0/publish/wwwroot/.nojekyll
run: touch src/WebConverter/bin/Release/net9.0/publish/wwwroot/.nojekyll
- name: Update service-worker-assets.js hashes
working-directory: src/WebConverter/bin/Release/net8.0/publish/wwwroot
working-directory: src/WebConverter/bin/Release/net9.0/publish/wwwroot
if: false
run: |
jsFile=$(<service-worker-assets.js)
Expand Down Expand Up @@ -74,7 +75,7 @@ jobs:
- name: Upload pages artifact
uses: actions/upload-pages-artifact@main
with:
path: src/WebConverter/bin/Release/net8.0/publish/wwwroot
path: src/WebConverter/bin/Release/net9.0/publish/wwwroot
deploy:
name: Deploy
needs: publish
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/githubpages_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: 8.x
dotnet-version: 9.x
dotnet-quality: 'ga'
- name: Setup .NET workload maui-android
run: dotnet workload install maui-android
- name: Setup .NET workload maui-ios
Expand All @@ -41,9 +42,9 @@ jobs:
- name: Publish
run: dotnet publish src/WebConverter/WebConverter.csproj -c Release -p:PublishProfile=src/WebConverter/Properties/PublishProfiles/PublishSite.pubxml -p:VersionSuffix=ci --no-restore
- name: Create .nojekyll file
run: touch src/WebConverter/bin/Release/net8.0/publish/wwwroot/.nojekyll
run: touch src/WebConverter/bin/Release/net9.0/publish/wwwroot/.nojekyll
- name: Update service-worker-assets.js hashes
working-directory: src/WebConverter/bin/Release/net8.0/publish/wwwroot
working-directory: src/WebConverter/bin/Release/net9.0/publish/wwwroot
if: false
run: |
jsFile=$(<service-worker-assets.js)
Expand Down Expand Up @@ -75,7 +76,7 @@ jobs:
- name: Upload pages artifact
uses: actions/upload-pages-artifact@main
with:
path: src/WebConverter/bin/Release/net8.0/publish/wwwroot
path: src/WebConverter/bin/Release/net9.0/publish/wwwroot
deploy:
name: Deploy
needs: publish
Expand All @@ -99,4 +100,4 @@ jobs:
id: deployment
uses: actions/deploy-pages@main
with:
preview: true
preview: true
20 changes: 1 addition & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,6 @@ Call a static method from `PDFtoImage.Conversion`:
https://github.com/sungaila/PDFtoImage.git?path=etc/UnityPackage
```

## Breaking changes in v4.0.0
Starting with v4.0.0 the struct `RenderOptions` is used for most methods. This is a breaking change when updating from v3.1.0 and older.
### Option 1: Migrate to new API
```csharp
// this will not compile anymore
PDFtoImage.Conversion.SaveJpeg("image.jpg", pdfStream, dpi: 300, rotation: PdfRotation.Rotate90);

// use this instead
PDFtoImage.Conversion.SaveJpeg("image.jpg", pdfStream, options: new(Dpi: 300, Rotation: PdfRotation.Rotate90));
```
### Option 2: Change namespace
Note: This namespace is used for backward compatibility and will be removed in a future version.
```csharp
using PDFtoImage;
using Conversion = PDFtoImage.Compatibility.Conversion;
```

## Supported runtimes
* [.NET (Core)](https://learn.microsoft.com/en-us/dotnet/core/introduction)
* [.NET Framework](https://learn.microsoft.com/en-us/dotnet/framework/get-started/overview)
Expand All @@ -60,5 +43,4 @@ using Conversion = PDFtoImage.Compatibility.Conversion;
* [.NET Multi-platform App UI (.NET MAUI)](https://learn.microsoft.com/en-us/dotnet/maui/what-is-maui) (excluding **macOS**)
* [Unity](https://docs.unity3d.com/Manual/Mono.html)
* [Universal Windows Platform (UWP)](https://learn.microsoft.com/en-us/windows/uwp/get-started/universal-application-platform-guide)
* [Windows UI Library 3 (WinUI 3)](https://learn.microsoft.com/en-us/windows/apps/winui/winui3/)
* [Xamarin.Android](https://learn.microsoft.com/en-us/xamarin/android)
* [Windows UI Library 3 (WinUI 3)](https://learn.microsoft.com/en-us/windows/apps/winui/winui3/)
4 changes: 2 additions & 2 deletions src/Console/Console.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- Assembly -->
<PropertyGroup>
<TargetFrameworks>net462;net471;net481;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net462;net471;net481;net6.0;net8.0;net9.0</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<OutputType>Exe</OutputType>
<AssemblyName>PDFtoImage.Console</AssemblyName>
<RootNamespace>PDFtoImage.Console</RootNamespace>
<StartupObject>PDFtoImage.Console.Program</StartupObject>
<Version>4.1.1</Version>
<Version>5.0.0</Version>
<Configurations>Debug;Release;ReleaseSigned</Configurations>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/FrameworkTests/AotConsole/AotConsole.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<TargetFramework>net9.0</TargetFramework>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;linux-musl-x64;linux-musl-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>PDFtoImage.FrameworkTests.AotConsole</AssemblyName>
Expand Down
26 changes: 26 additions & 0 deletions src/FrameworkTests/AotConsole/Dockerfiles/alpine-aot.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM mcr.microsoft.com/dotnet/runtime:9.0-alpine AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS restore
ARG BUILD_CONFIGURATION=Release
RUN apk update \
&& apk add build-base zlib-dev
WORKDIR /src
COPY ["src/FrameworkTests/AotConsole/AotConsole.csproj", "src/FrameworkTests/AotConsole/AotConsole.csproj"]
COPY ["src/PDFtoImage", "src/PDFtoImage"]
RUN dotnet restore "./src/FrameworkTests/AotConsole/AotConsole.csproj" /p:TargetFramework=net9.0
COPY . .
WORKDIR "/src/src"

FROM restore AS build
ARG BUILD_CONFIGURATION=Release
RUN dotnet build "./FrameworkTests/AotConsole/AotConsole.csproj" -c $BUILD_CONFIGURATION -o /app/build --no-restore

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./FrameworkTests/AotConsole/AotConsole.csproj" -c $BUILD_CONFIGURATION -o /app/publish --no-restore

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["./PDFtoImage.FrameworkTests.AotConsole"]
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
FROM mcr.microsoft.com/dotnet/runtime:8.0-nanoserver-ltsc2022 AS base
FROM mcr.microsoft.com/dotnet/runtime:9.0-alpine AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0-windowsservercore-ltsc2022 AS restore
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS restore
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/FrameworkTests/AotConsole/AotConsole.csproj", "src/FrameworkTests/AotConsole/AotConsole.csproj"]
COPY ["src/PDFtoImage", "src/PDFtoImage"]
RUN dotnet restore "./src/FrameworkTests/AotConsole/AotConsole.csproj" /p:TargetFramework=net8.0
RUN dotnet restore "./src/FrameworkTests/AotConsole/AotConsole.csproj" /p:TargetFramework=net9.0
COPY . .
WORKDIR "/src/src"

FROM restore AS build
ARG BUILD_CONFIGURATION=Release
RUN dotnet build "./FrameworkTests/AotConsole/AotConsole.csproj" -c %BUILD_CONFIGURATION% -o /app/build --no-restore
RUN dotnet build "./FrameworkTests/AotConsole/AotConsole.csproj" -c $BUILD_CONFIGURATION -o /app/build --no-restore

FROM base AS final
WORKDIR /app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0 AS base
FROM mcr.microsoft.com/dotnet/runtime-deps:9.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS restore
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS restore
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/FrameworkTests/AotConsole/AotConsole.csproj", "src/FrameworkTests/AotConsole/AotConsole.csproj"]
COPY ["src/PDFtoImage", "src/PDFtoImage"]
RUN dotnet restore "./src/FrameworkTests/AotConsole/AotConsole.csproj" /p:TargetFramework=net8.0
RUN dotnet restore "./src/FrameworkTests/AotConsole/AotConsole.csproj" /p:TargetFramework=net9.0
COPY . .
WORKDIR "/src/src"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-noble-chiseled AS base
FROM mcr.microsoft.com/dotnet/runtime-deps:9.0-noble-chiseled AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS restore
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS restore
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/FrameworkTests/AotConsole/AotConsole.csproj", "src/FrameworkTests/AotConsole/AotConsole.csproj"]
COPY ["src/PDFtoImage", "src/PDFtoImage"]
RUN dotnet restore "./src/FrameworkTests/AotConsole/AotConsole.csproj" /p:TargetFramework=net8.0
RUN dotnet restore "./src/FrameworkTests/AotConsole/AotConsole.csproj" /p:TargetFramework=net9.0
COPY . .
WORKDIR "/src/src"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM mcr.microsoft.com/dotnet/runtime:8.0-noble-chiseled AS base
FROM mcr.microsoft.com/dotnet/runtime:9.0-noble-chiseled AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS restore
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS restore
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/FrameworkTests/AotConsole/AotConsole.csproj", "src/FrameworkTests/AotConsole/AotConsole.csproj"]
COPY ["src/PDFtoImage", "src/PDFtoImage"]
RUN dotnet restore "./src/FrameworkTests/AotConsole/AotConsole.csproj" /p:TargetFramework=net8.0
RUN dotnet restore "./src/FrameworkTests/AotConsole/AotConsole.csproj" /p:TargetFramework=net9.0
COPY . .
WORKDIR "/src/src"

Expand Down
6 changes: 3 additions & 3 deletions src/FrameworkTests/AotConsole/Dockerfiles/ubuntu.dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
FROM mcr.microsoft.com/dotnet/runtime:9.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS restore
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS restore
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/FrameworkTests/AotConsole/AotConsole.csproj", "src/FrameworkTests/AotConsole/AotConsole.csproj"]
COPY ["src/PDFtoImage", "src/PDFtoImage"]
RUN dotnet restore "./src/FrameworkTests/AotConsole/AotConsole.csproj" /p:TargetFramework=net8.0
RUN dotnet restore "./src/FrameworkTests/AotConsole/AotConsole.csproj" /p:TargetFramework=net9.0
COPY . .
WORKDIR "/src/src"

Expand Down
Loading

0 comments on commit d61f1d1

Please sign in to comment.