Skip to content

Commit cac5c7f

Browse files
Build Android on Linux (#1755)
* Build Android targets on Linux * Remove solution filters * Update build * Update workloads * Set temp dir for workload installation
1 parent 561edc8 commit cac5c7f

File tree

9 files changed

+29
-200
lines changed

9 files changed

+29
-200
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ jobs:
2323
matrix:
2424
# Using macos-12 because we need Xcode 13.3 or later to build Sentry.Samples.Maui. (macos-latest currently points at macos-11 which uses Xcode 13.2)
2525
os: [ubuntu-latest, windows-latest, macos-12]
26-
include:
27-
- os: ubuntu-latest
28-
slnf: SentryLinux.slnf
29-
- os: windows-latest
30-
slnf: SentryWindows.slnf
31-
- os: macos-12
32-
slnf: SentryMac.slnf
3326

3427
steps:
3528
- name: Checkout
@@ -61,38 +54,29 @@ jobs:
6154
path: ~/.nuget/packages
6255
# We don't use a lockfile, so hash all files where we might be keeping <PackageReference> tags
6356
# Workloads also get installed in the nuget packages cache, so if you modify workloads below, increment the number in the cache keys
64-
key: ${{ runner.os }}-nuget+workloads2-${{ hashFiles('**/*.*proj', '**/*.props') }}
65-
restore-keys: ${{ runner.os }}-nuget+workloads2
57+
key: ${{ runner.os }}-nuget+workloads3-${{ hashFiles('**/*.*proj', '**/*.props') }}
58+
restore-keys: ${{ runner.os }}-nuget+workloads3
6659

67-
# .NET Android workloads don't support Linux https://github.com/dotnet/sdk/issues/22411
60+
- name: Install .NET Workloads (Ubuntu)
61+
if: startsWith(matrix.os, 'ubuntu')
62+
run: 'dotnet workload install maui-android --temp-dir "${{ runner.temp }}"'
6863
- name: Install .NET Workloads (Windows)
6964
if: startsWith(matrix.os, 'windows')
70-
run: dotnet workload install maui-android maui-windows
65+
run: 'dotnet workload install maui-android maui-windows --temp-dir "${{ runner.temp }}"'
7166
- name: Install .NET Workloads (macOS)
7267
if: startsWith(matrix.os, 'macos')
73-
run: dotnet workload install maui-android maui-ios maui-maccatalyst
68+
run: 'dotnet workload install maui-android maui-ios maui-maccatalyst --temp-dir "${{ runner.temp }}"'
7469

7570
- name: Build
76-
run: dotnet build ${{ matrix.slnf }} -c Release /p:CopyLocalLockFileAssemblies=true
71+
run: dotnet build -c Release /p:CopyLocalLockFileAssemblies=true
7772

7873
- name: Test
79-
run: dotnet test ${{ matrix.slnf }} -c Release --no-build -l GitHubActions -l "trx;LogFileName=${{ matrix.os }}-test-results.trx"
80-
81-
# - name: Create Test Report
82-
# uses: phoenix-actions/test-reporting@4b942144e31c4039ac808d9b29945864b628a574
83-
# # run this step even if previous step failed
84-
# if: success() || failure()
85-
# with:
86-
# name: Unit Test Results (${{ matrix.os }})
87-
# path: '**/*.trx'
88-
# reporter: dotnet-trx
89-
# list-suites: 'failed'
90-
# list-tests: 'failed'
74+
run: dotnet test -c Release --no-build -l GitHubActions -l "trx;LogFileName=${{ matrix.os }}-test-results.trx"
9175

9276
- name: Pack
9377
# Only pack in one build environment. We'll use macOS so we can build for ios/maccatalyst targets
9478
if: startsWith(matrix.os, 'macos')
95-
run: dotnet pack ${{ matrix.slnf }} -c Release --no-build
79+
run: dotnet pack -c Release --no-build
9680

9781
- name: Upload Verify Results
9882
if: failure()

.github/workflows/codeql-analysis.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ jobs:
3131
uses: actions/cache@v3
3232
with:
3333
path: ~/.nuget/packages
34-
## we don't use a lockfile, so hash all files where we might be keeping <PackageReference> tags
35-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.*proj', '**/*.props') }}
36-
restore-keys: ${{ runner.os }}-nuget
34+
# We don't use a lockfile, so hash all files where we might be keeping <PackageReference> tags
35+
# Workloads also get installed in the nuget packages cache, so if you modify workloads below, increment the number in the cache keys
36+
key: ${{ runner.os }}-nuget+workloads3-${{ hashFiles('**/*.*proj', '**/*.props') }}
37+
restore-keys: ${{ runner.os }}-nuget+workloads3
38+
39+
- name: Install .NET Workloads (Ubuntu)
40+
run: 'dotnet workload install maui-android --temp-dir "${{ runner.temp }}"'
3741

3842
# Initializes the CodeQL tools for scanning.
3943
- name: Initialize CodeQL
@@ -42,10 +46,9 @@ jobs:
4246
languages: ${{ matrix.language }}
4347

4448
- name: Build
45-
# TODO: Won't run over code specific to Windows or macOS
46-
# Prob best to use reusable workflows to have the setup shared with build.yml
49+
# TODO: Prob best to use reusable workflows to have the setup shared with build.yml
4750
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow
48-
run: dotnet build SentryLinux.slnf
51+
run: dotnet build
4952

5053
- name: Perform CodeQL Analysis
5154
uses: github/codeql-action/analyze@v2

SentryLinux.slnf

Lines changed: 0 additions & 48 deletions
This file was deleted.

SentryMac.slnf

Lines changed: 0 additions & 52 deletions
This file was deleted.

SentryWindows.slnf

Lines changed: 0 additions & 52 deletions
This file was deleted.

build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ $ErrorActionPreference = "Stop"
22

33
$testLogger = if ($env:GITHUB_ACTIONS -eq "true") {"GitHubActions;report-warnings=false"} else {"console"}
44

5-
dotnet test SentryWindows.slnf -c Release -l $testLogger `
5+
dotnet test -c Release -l $testLogger `
66
/p:CopyLocalLockFileAssemblies=true
77
if ($LASTEXITCODE -ne 0) { exit 1 }
88

9-
dotnet pack SentryWindows.slnf -c Release --no-build
9+
dotnet pack -c Release --no-build
1010
if ($LASTEXITCODE -ne 0) { exit 1 }

build.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,5 @@ if [ "$GITHUB_ACTIONS" == "true" ]
88
testLogger="console"
99
fi
1010

11-
case "$OSTYPE" in
12-
darwin*) export Filter=SentryMac.slnf ;;
13-
linux*) export Filter=SentryLinux.slnf ;;
14-
*) echo Unsupported $OSTYPE && exit -1 ;;
15-
esac
16-
17-
dotnet test $Filter -c Release -l $testLogger \
11+
dotnet test -c Release -l $testLogger \
1812
/p:CopyLocalLockFileAssemblies=true

samples/Sentry.Samples.Maui/Sentry.Samples.Maui.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
<PropertyGroup>
44
<!--
5-
On Mac, we'll build for Android, iOS, and MacCatalyst.
6-
On Windows, we'll build for Android and Windows 10
5+
We can build for Android from all build platforms.
6+
On Mac, we'll also build for iOS and MacCatalyst.
7+
On Windows, we'll also build for Windows 10.
78
-->
8-
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">net6.0-android;net6.0-windows10.0.19041.0</TargetFrameworks>
9-
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
9+
<TargetFrameworks>net6.0-android</TargetFrameworks>
10+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
11+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
1012
<OutputType>Exe</OutputType>
1113
<RootNamespace>Sentry.Samples.Maui</RootNamespace>
1214
<UseMaui>true</UseMaui>

src/Sentry/Sentry.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;net5.0;netcoreapp3.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
5-
<!-- .NET Android Workload doesn't support Linux -->
6-
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('Linux'))">$(TargetFrameworks);net6.0-android</TargetFrameworks>
4+
<TargetFrameworks>net6.0;net5.0;netcoreapp3.0;netstandard2.1;netstandard2.0;net461;net6.0-android</TargetFrameworks>
75
<!-- We'll pin to C# 9 and ImplicitUsings false to allow us to compile within Unity -->
86
<LangVersion>9</LangVersion>
97
<ImplicitUsings>false</ImplicitUsings>

0 commit comments

Comments
 (0)