Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Mono #60

Merged
merged 23 commits into from
Jan 24, 2024
Merged
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
63 changes: 49 additions & 14 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,16 @@ jobs:
java-version: 17
java-package: jdk
distribution: 'zulu'
- name: Setup Android SDK 29
run: C:\Android\android-sdk\cmdline-tools\latest\bin\sdkmanager "platforms;android-29"
- name: Restore
run: msbuild src/PDFtoImage.sln /t:restore
- name: Build
run: msbuild src/PDFtoImage.sln /p:Configuration=${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} /p:VersionSuffix=ci /p:RestorePackages=false
- name: Pack
run: msbuild src/PDFtoImage/PDFtoImage.csproj /t:pack /p:Configuration=${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} /p:VersionSuffix=ci /p:RestorePackages=false
- name: Publish libraries
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v4
with:
name: Library assemblies
path: |
Expand All @@ -110,21 +112,29 @@ jobs:
!**/*.snupkg
if-no-files-found: error
- name: Publish NuGet packages
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v4
with:
name: NuGet packages
path: |
src/PDFtoImage/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/*.nupkg
src/PDFtoImage/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/*.snupkg
if-no-files-found: error
- name: Publish tests
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v3
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true
with:
name: Test assemblies
path: src/Tests/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}
if-no-files-found: error
retention-days: 1
- name: Publish test project MonoConsole
uses: actions/upload-artifact@v4
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
Expand All @@ -135,6 +145,9 @@ jobs:
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 6
uses: actions/setup-dotnet@main
with:
Expand All @@ -147,35 +160,53 @@ jobs:
uses: actions/setup-dotnet@main
with:
dotnet-version: 8.x
- name: Download test project MonoConsole
uses: actions/download-artifact@v4
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
- name: Download test assemblies
uses: actions/download-artifact@main
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: Test assemblies
- name: .NET Framework 4.6.2
if: runner.os == 'Windows' && success()
run: dotnet test net462/*.Tests.dll --logger trx --verbosity detailed ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net462/SaveOutputInGeneratedFolder.runsettings' || '' }}
if: runner.os == 'Windows' && (success() || failure())
run: dotnet test net462/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net462/SaveOutputInGeneratedFolder.runsettings' || '' }}
- name: .NET Framework 4.7.1
if: runner.os == 'Windows' && (success() || failure())
run: dotnet test net471/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net471/SaveOutputInGeneratedFolder.runsettings' || '' }}
- name: .NET Framework 4.8.1
if: runner.os == 'Windows' && (success() || failure())
run: dotnet test net481/*.Tests.dll --logger trx --verbosity detailed ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net481/SaveOutputInGeneratedFolder.runsettings' || '' }}
run: dotnet test net481/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net481/SaveOutputInGeneratedFolder.runsettings' || '' }}
- name: .NET 6
if: success() || failure()
run: dotnet test net6.0/*.Tests.dll --logger trx --verbosity detailed ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net6.0/SaveOutputInGeneratedFolder.runsettings' || '' }}
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 ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net7.0/SaveOutputInGeneratedFolder.runsettings' || '' }}
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 net7.0/SaveOutputInGeneratedFolder.runsettings' || '' }}
- name: .NET 8
if: success() || failure()
run: dotnet test net8.0/*.Tests.dll --logger trx --verbosity detailed ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net8.0/SaveOutputInGeneratedFolder.runsettings' || '' }}
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: Upload test results
if: success() || failure()
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v4
with:
name: Test results (${{ matrix.os }})
path: ./**/*.trx
retention-days: 1
- name: Upload generated assets
if: (success() || failure()) && (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v4
with:
name: Generated assets (${{ matrix.os }})
path: ./**/Assets/Generated
Expand All @@ -193,8 +224,10 @@ jobs:
if: (success() || failure()) && (github.event_name != 'workflow_dispatch' && true || inputs.publish_testresults) == true
steps:
- name: Download Artifacts
uses: actions/download-artifact@main
uses: actions/download-artifact@v4
with:
pattern: Test results (*)
merge-multiple: true
path: artifacts
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@master
Expand Down Expand Up @@ -249,6 +282,8 @@ jobs:
java-version: 17
java-package: jdk
distribution: 'zulu'
- name: Setup Android SDK 29
run: C:\Android\android-sdk\cmdline-tools\latest\bin\sdkmanager "platforms;android-29"
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -278,4 +313,4 @@ jobs:
dotnet restore src/PDFtoImage.SonarCloud.slnf
msbuild src/PDFtoImage.SonarCloud.slnf /p:Configuration=${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}
dotnet-coverage collect "dotnet test src/PDFtoImage.SonarCloud.slnf --verbosity detailed" -f xml -o "coverage.xml"
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
2 changes: 1 addition & 1 deletion .github/workflows/githubpages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:

concurrency:
group: "pages"
cancel-in-progress: false
cancel-in-progress: true

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/githubpages_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:

concurrency:
group: "pages"
cancel-in-progress: false
cancel-in-progress: true

steps:
- name: Deploy to GitHub Pages
Expand Down
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;net481;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net462;net471;net481;net6.0;net7.0;net8.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>3.0.0</Version>
<Version>3.1.0</Version>
<Configurations>Debug;Release;ReleaseSigned</Configurations>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/FrameworkTests/MauiApp/MauiApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.3" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.3" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.6" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.6" />
</ItemGroup>

<ItemGroup>
Expand Down
53 changes: 53 additions & 0 deletions src/FrameworkTests/MonoConsole/MonoConsole.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;net471;net481</TargetFrameworks>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<AssemblyName>PDFtoImage.FrameworkTests.MonoConsole</AssemblyName>
<RootNamespace>PDFtoImage.FrameworkTests.MonoConsole</RootNamespace>
</PropertyGroup>

<!-- C# compiler -->
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<Features>strict</Features>
<WarningsAsErrors>nullable</WarningsAsErrors>
<NoWarn>CA1416</NoWarn>
</PropertyGroup>

<!-- Remove these libs when updating pdfium nuget packages -->
<ItemGroup>
<None Remove="linux-arm64\libpdfium.so" />
<None Remove="linux-x64\libpdfium.so" />
<None Remove="linux-x86\libpdfium.so" />
<None Remove="osx-x64\libpdfium.dylib" />
</ItemGroup>

<ItemGroup>
<Content Include="..\..\Tests\Assets\SocialPreview.pdf" Link="SocialPreview.pdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="linux-arm64\libpdfium.so">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>arm64\libpdfium.so</TargetPath>
</Content>
<Content Include="linux-x64\libpdfium.so">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>x64\libpdfium.so</TargetPath>
</Content>
<Content Include="linux-x86\libpdfium.so">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>x86\libpdfium.so</TargetPath>
</Content>
<Content Include="osx-x64\libpdfium.dylib">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>libpdfium.dylib</TargetPath>
</Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\PDFtoImage\PDFtoImage.csproj" />
</ItemGroup>
</Project>
23 changes: 23 additions & 0 deletions src/FrameworkTests/MonoConsole/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.IO;

namespace PDFtoImage.FrameworkTests.MonoConsole
{
public class Program
{
private const int ExpectedWidth = 5333;
private const int ExpectedHeight = 2666;

public static void Main()
{
Directory.SetCurrentDirectory(Path.GetDirectoryName(typeof(Program).Assembly.Location));
using var input = new FileStream("SocialPreview.pdf", FileMode.Open, FileAccess.Read);
using var bitmap = PDFtoImage.Conversion.ToImage(input);

Console.WriteLine($"SocialPreview.pdf size: {bitmap.Width}x{bitmap.Height}");

if (ExpectedWidth != bitmap.Width || ExpectedHeight != bitmap.Height)
throw new InvalidOperationException("Expected PDF width and height differ.");
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions src/PDFtoImage.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiApp", "FrameworkTests\M
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore", "FrameworkTests\AspNetCore\AspNetCore.csproj", "{451B5027-1F18-4132-B5AF-DB752DDE91FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoConsole", "FrameworkTests\MonoConsole\MonoConsole.csproj", "{4453B6F1-0470-420A-BD2C-7BE64EE8E256}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -81,6 +83,12 @@ Global
{451B5027-1F18-4132-B5AF-DB752DDE91FD}.Release|Any CPU.Build.0 = Release|Any CPU
{451B5027-1F18-4132-B5AF-DB752DDE91FD}.ReleaseSigned|Any CPU.ActiveCfg = Release|Any CPU
{451B5027-1F18-4132-B5AF-DB752DDE91FD}.ReleaseSigned|Any CPU.Build.0 = Release|Any CPU
{4453B6F1-0470-420A-BD2C-7BE64EE8E256}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4453B6F1-0470-420A-BD2C-7BE64EE8E256}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4453B6F1-0470-420A-BD2C-7BE64EE8E256}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4453B6F1-0470-420A-BD2C-7BE64EE8E256}.Release|Any CPU.Build.0 = Release|Any CPU
{4453B6F1-0470-420A-BD2C-7BE64EE8E256}.ReleaseSigned|Any CPU.ActiveCfg = Release|Any CPU
{4453B6F1-0470-420A-BD2C-7BE64EE8E256}.ReleaseSigned|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -89,6 +97,7 @@ Global
{E6458852-9C48-48CE-AC1C-99374F3B3092} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0}
{F1B387C4-5E76-4079-991A-ED6684112317} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0}
{451B5027-1F18-4132-B5AF-DB752DDE91FD} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0}
{4453B6F1-0470-420A-BD2C-7BE64EE8E256} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D6C1E6C9-335A-4797-9F4E-2DEB42A9B295}
Expand Down
Loading
Loading