Skip to content

Commit

Permalink
Merge branch 'main' into maybe-fix-zip
Browse files Browse the repository at this point in the history
* main:
  Add Unit Test for testOnly apps (dotnet#7637)
  [build] Only build the latest API level (dotnet#7786)
  [Xamarin.Android.Build.Tasks] Improve aapt2+file not found handling (dotnet#7644)
  [MSBuildDeviceIntegration] Fix duplicated test parameter (dotnet#7809)
  [tests] Bump NUnit versions to latest (dotnet#7802)
  [Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily (dotnet#7803)
  [tests] `InstallAndroidDependenciesTest` can use `platform-tools` 34.0.0 (dotnet#7800)
  Bump to xamarin/Java.Interop/main@9e0a469 (dotnet#7797)
  [Xamarin.Android.Build.Tasks] FileWrites&libraryprojectimports.cache (dotnet#7780)
  Bump to dotnet/installer@d25a3bb 8.0.100-preview.2.23105.6 (dotnet#7769)
  [lgtm] Fix LGTM-reported issues (dotnet#1074)
  [ci] Report issues in the API docs build log (dotnet#7784)
  • Loading branch information
grendello committed Feb 22, 2023
2 parents f11a5ca + 41748e1 commit 02b022b
Show file tree
Hide file tree
Showing 37 changed files with 706 additions and 864 deletions.
2 changes: 2 additions & 0 deletions .lgtm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
queries:
- exclude: cs/campaign/constantine
5 changes: 0 additions & 5 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@
<_StandardLibraryPath Condition=" '$(TargetFrameworkVersion)' == '' ">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPathToStandardLibraries('.NETFramework', 'v4.7.2', ''))</_StandardLibraryPath>
<TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' And '$(UsingMicrosoftNETSdk)' != 'true' And '$(_StandardLibraryPath)' != '' ">v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' And '$(UsingMicrosoftNETSdk)' != 'true' ">v4.7.1</TargetFrameworkVersion>
<!-- Used by the `build-tools/create-vsix` build so that `Mono.Android.Export.dll`/etc. are only included *once* -->
<!-- Should correspond to the first value from `$(API_LEVELS)` in `build-tools/api-xml-adjuster/Makefile` -->
<AndroidFirstFrameworkVersion Condition="'$(AndroidFirstFrameworkVersion)' == ''">v4.4</AndroidFirstFrameworkVersion>
<AndroidFirstApiLevel Condition="'$(AndroidFirstApiLevel)' == ''">19</AndroidFirstApiLevel>
<AndroidJavaRuntimeApiLevel Condition="'$(AndroidJavaRuntimeApiLevel)' == ''">26</AndroidJavaRuntimeApiLevel>
<!-- The min API level supported by Microsoft.Android.Sdk, should refactor/remove when this value is the same as $(AndroidFirstApiLevel) -->
<AndroidMinimumDotNetApiLevel Condition="'$(AndroidMinimumDotNetApiLevel)' == ''">21</AndroidMinimumDotNetApiLevel>
<AndroidFirstPlatformId Condition="'$(AndroidFirstPlatformId)' == ''">$(AndroidFirstApiLevel)</AndroidFirstPlatformId>
<!-- *Latest* *stable* API level binding that we support; used when building src/Xamarin.Android.Build.Tasks -->
<AndroidLatestStableApiLevel Condition="'$(AndroidLatestStableApiLevel)' == ''">33</AndroidLatestStableApiLevel>
<AndroidLatestStablePlatformId Condition="'$(AndroidLatestStablePlatformId)' == ''">$(AndroidLatestStableApiLevel)</AndroidLatestStablePlatformId>
Expand Down
5 changes: 0 additions & 5 deletions Documentation/building/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ Overridable MSBuild properties include:
This is an integer value, e.g. `15` for
[API-15 (Android 4.0.3)](http://developer.android.com/about/versions/android-4.0.3.html).

* `$(AndroidFirstFrameworkVersion)`: The first `$(TargetFrameworkVersion)`
which will be built by `make jenkins` and included in the installer.
Currently `v4.4`.
This controls what is included in `build-tools/create-vsix` packages.

* `$(AndroidFrameworkVersion)`: The Xamarin.Android `$(TargetFrameworkVersion)`
version which corresponds to `$(AndroidApiLevel)`. This is *usually* the
Android version number with a leading `v`, e.g. `v4.0.3` for API-15.
Expand Down
1 change: 1 addition & 0 deletions Documentation/guides/messages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ms.date: 01/24/2020
+ APT0002: Invalid file name: It must contain only \[^a-zA-Z0-9_.-\]+.
+ APT0003: Invalid file name: It must contain only \[^a-zA-Z0-9_.\]+.
+ APT0004: Invalid file name: It must start with either A-Z or a-z or an underscore.
+ [APT2264](apt2264.md): The system cannot find the file specified. (2).

## JAVAxxxx: Java Tool

Expand Down
58 changes: 58 additions & 0 deletions Documentation/guides/messages/apt2264.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: Xamarin.Android error APT2264
description: APT2264 error code
ms.date: 12/16/2022
---
# Xamarin.Android error APT2264

## Issue

The tool `aapt2` is unable to resolve one of the files it was passed.
This is generally caused by the path being longer than the Maximum Path
length allowed on windows.

## Solution

The best way to avoid this is to ensure that your project is not located
deep in the folder structure. For example if you create all of your
projects in folders such as

`C:\Users\shelly\Visual Studio\Android\MyProjects\Com.SomeReallyLongCompanyName.MyBrillantApplication\MyBrilliantApplicaiton.Android\`

you may well encounter problems with not only `aapt2` but also Ahead of Time
compilation. Keeping your project names and folder structures short and
concise will help work around these issues. For example instead of the above
you could use

`C:\Work\Android\MyBrilliantApp`

Which is much shorter and much less likely to encounter path issues.

However this is no always possible. Sometimes a project or a environment requires
deep folder structures. In this case enabling long path support in Windows *might*
be enough to get your project working. Details on how to do this can be found
[here](https://learn.microsoft.com/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#enable-long-paths-in-windows-10-version-1607-and-later).


If long path support does not work changing the location of the
`$(BaseIntermediateOutputPath)` can help solve these problems. In order for this
to work the setting MUST be changed before ANY build or restore occurs. To do this
you can make use of the MSBuild `Directory.Build.props` support.

Creating a `Directory.Build.props` file in your solution or project directory which
redefines the `$(BaseIntermediateOutputPath)` to somewhere nearer the root of the drive
with solve these issues. Adding a file with the following contents will create the `obj`
directory in a different location of your choosing.

```
<Project>
<PropertyGroup>
<BaseIntermediateOutputPath Condition=" '$(OS)' == 'Windows_NT' ">C:\Intermediate\$(ProjectName)</BaseIntermediateOutputPath>
<BaseIntermediateOutputPath Condition=" '$(OS)' != 'Windows_NT' ">/tmp/Intermediate/$(ProjectName)</BaseIntermediateOutputPath>
</PropertyGroup>
</Project
```

Using this technique will reduce the lengths of the paths sent to the various tools like `aapt2`.
Note this is generally only a Windows issue. So there is no need to override the `$(BaseIntermediateOutputPath)`
on Mac or Linux based environments. However you might want to override everywhere to be consistent.
2 changes: 1 addition & 1 deletion build-tools/api-xml-adjuster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ API_XML_TOOL = $(BUILDBIN)/api-xml-adjuster.exe
RUNTIME = mono --debug
RUN_CLASS_PARSE = $(RUNTIME) $(CLASS_PARSE)
RUN_API_XML_TOOL = $(RUNTIME) $(API_XML_TOOL)
API_LEVELS = 10 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
API_LEVELS = 33

XML_OUTPUT_DIR = .

Expand Down
22 changes: 22 additions & 0 deletions build-tools/automation/azure-pipelines-apidocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,25 @@ stages:
inputs:
artifactName: Api Docs Diff
targetPath: $(Build.StagingDirectory)/api-doc-diff

- powershell: |
$docsUpdateBinlog = Get-ChildItem -Path "$(Build.SourcesDirectory)/bin/Build$(XA.Build.Configuration)" -Filter *UpdateApiDocs-*.binlog | Select-Object -First 1
$buildLog = "$(Build.SourcesDirectory)/bin/Build$(XA.Build.Configuration)/temp-build.log"
& "$(Build.SourcesDirectory)/bin/$(XA.Build.Configuration)/dotnet/dotnet" build $docsUpdateBinlog > $buildLog
$issueContent = & {
Get-Content -Path $buildLog | Select-String "## Exception translating remarks"
Get-Content -Path $buildLog | Select-String "## Unable to translate remarks"
Get-Content -Path $buildLog | Select-String "JavadocImport-"
}
if ($issueContent) {
Write-Host "The following issues were found, review the build log for more details:"
Write-Host ""
foreach ($line in $issueContent) {
Write-Host $line
Write-Host ""
}
exit 1
}
displayName: Report issues in docs generation
176 changes: 0 additions & 176 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ resources:
name: xamarin/release-scripts
ref: refs/heads/sign-and-notarized
endpoint: xamarin
- repository: uitools
type: github
name: xamarin/UITools
ref: refs/heads/main
endpoint: xamarin

parameters:
- name: provisionatorChannel
Expand Down Expand Up @@ -697,11 +692,6 @@ stages:
target_framework: $(DotNetStableTargetFramework)
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- stage: wear_tests
displayName: WearOS Tests
dependsOn: mac_build
condition: and(succeeded(), or(eq(variables['RunAllTests'], true), contains(dependencies.mac_build.outputs['mac_build_create_installers.TestConditions.TestAreas'], 'MSBuildDevice')))
jobs:
- job: wear_tests
displayName: macOS > Tests > WearOS
timeoutInMinutes: 180
Expand Down Expand Up @@ -771,172 +761,6 @@ stages:
- template: yaml-templates/fail-on-issue.yaml



- stage: designer_tests
displayName: Designer Tests
dependsOn: mac_build
condition: and(succeeded(), or(eq(variables['RunAllTests'], true), contains(dependencies.mac_build.outputs['mac_build_create_installers.TestConditions.TestAreas'], 'Designer')))
jobs:
# Check - "Xamarin.Android (macOS > Tests > Designer Integration)"
- job: designer_integration_mac
condition: false #TODO: Enable once test issues are fixed.
displayName: macOS > Tests > Designer Integration
pool:
vmImage: $(HostedMacImage)
timeoutInMinutes: 120
cancelTimeoutInMinutes: 5
workspace:
clean: all
variables:
EnableRegressionTest: true
steps:
- checkout: uitools
clean: true
submodules: recursive
path: s/UITools
persistCredentials: true

- powershell: |
# Use the branch name of the source being built or the PR target branch name. Fall back to 'main' if the branch is unknown.
$branchPrefix = "/refs/heads/"
$branchName = "$(Build.SourceBranch)" -replace $branchPrefix, ""
if ("$(Build.Reason)" -eq "PullRequest") {
$branchName = "$(System.PullRequest.TargetBranch)" -replace $branchPrefix, ""
}
if (("$branchName" -ne "main") -and ("$branchName" -notlike "d1*")) {
$branchName = "main"
}
Set-Location -Path $(System.DefaultWorkingDirectory)/UITools
git checkout $branchName
git submodule update -q --init --recursive
displayName: Clone and update UITools
- task: NuGetAuthenticate@0
displayName: authenticate with azure artifacts
inputs:
forceReinstallCredentialProvider: true

- task: provisionator@2
displayName: provision designer dependencies
inputs:
github_token: $(GitHub.Token)
provisioning_script: $(System.DefaultWorkingDirectory)/UITools/src/bot-provisioning/dependencies.csx
provisioning_extra_args: -remove Xamarin.Android -vv DEVDIV_PKGS_NUGET_TOKEN=$(DevDiv.NuGet.Token) SECTOOLS_PKGS_NUGET_TOKEN=$(SecTools.NuGet.Token)
env:
PROVISIONATOR_CHANNEL: ${{ parameters.provisionatorChannel }}

- template: yaml-templates/setup-test-environment.yaml
parameters:
xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android
jdkTestFolder: $(JAVA_HOME_8_X64)
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- template: designer/android-designer-build-mac.yaml@yaml-templates
parameters:
designerSourcePath: $(System.DefaultWorkingDirectory)/UITools/src

- template: designer/android-designer-tests.yaml@yaml-templates
parameters:
designerSourcePath: $(System.DefaultWorkingDirectory)/UITools/src
runAddinTests: false

- task: CopyFiles@2
displayName: 'Copy binlogs'
inputs:
sourceFolder: $(System.DefaultWorkingDirectory)/UITools/src/Xamarin.Designer.Android
contents: '**/*.binlog'
targetFolder: $(Build.ArtifactStagingDirectory)/designer-binlogs
overWrite: true
flattenFolders: true
condition: ne(variables['Agent.JobStatus'], 'Succeeded')

- template: yaml-templates/publish-artifact.yaml
parameters:
displayName: upload designer binlogs
artifactName: Test Results - Designer - macOS
targetPath: $(Build.ArtifactStagingDirectory)/designer-binlogs
condition: ne(variables['Agent.JobStatus'], 'Succeeded')

# Check - "Xamarin.Android (Windows > Tests > Designer Integration)"
- job: designer_integration_win
displayName: Windows > Tests > Designer Integration
pool:
vmImage: $(HostedWinImage)
timeoutInMinutes: 120
cancelTimeoutInMinutes: 5
workspace:
clean: all
variables:
EnableRegressionTest: true
RegressionTestSuiteOutputDir: C:\Git\ADesRegTestSuite
VisualStudioInstallationPath: C:\Program Files\Microsoft Visual Studio\2022\Enterprise
steps:
- checkout: uitools
clean: true
submodules: recursive
path: s\UITools
persistCredentials: true

- powershell: |
# Use the branch name of the source being built or the PR target branch name. Fall back to 'main' if the branch is unknown.
$branchPrefix = "/refs/heads/"
$branchName = "$(Build.SourceBranch)" -replace $branchPrefix, ""
if ("$(Build.Reason)" -eq "PullRequest") {
$branchName = "$(System.PullRequest.TargetBranch)" -replace $branchPrefix, ""
}
if (("$branchName" -ne "main") -and ("$branchName" -notlike "d1*")) {
$branchName = "main"
}
Set-Location -Path $(System.DefaultWorkingDirectory)\UITools
git checkout $branchName
git submodule update -q --init --recursive
displayName: Clone and update UITools
- task: NuGetAuthenticate@0
displayName: authenticate with azure artifacts
inputs:
forceReinstallCredentialProvider: true

- task: provisionator@2
displayName: provision designer dependencies
inputs:
github_token: $(GitHub.Token)
provisioning_script: $(System.DefaultWorkingDirectory)\UITools\src\bot-provisioning\dependencies.csx
provisioning_extra_args: -vv DEVDIV_PKGS_NUGET_TOKEN=$(DevDiv.NuGet.Token) SECTOOLS_PKGS_NUGET_TOKEN=$(SecTools.NuGet.Token)
env:
PROVISIONATOR_CHANNEL: ${{ parameters.provisionatorChannel }}

- template: yaml-templates\setup-test-environment.yaml
parameters:
xaSourcePath: $(System.DefaultWorkingDirectory)\xamarin-android
jdkTestFolder: $(JAVA_HOME_8_X64)
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- task: VSBuild@1
displayName: Restore Xamarin.AndroidDesigner
inputs:
solution: $(System.DefaultWorkingDirectory)\UITools\src\Xamarin.Designer.Android\Xamarin.AndroidDesigner.sln
vsVersion: 17.0
msbuildArgs: >-
/t:Restore /p:RestoreDisableParallel=true
/p:RestoreConfigFile="$(System.DefaultWorkingDirectory)\UITools\NuGet.Config"
/p:JavaSdkDirectory="$(JAVA_HOME_8_X64)"
platform: Any CPU
configuration: DebugWin32

- task: VSBuild@1
displayName: Build Xamarin.AndroidDesigner
inputs:
solution: $(System.DefaultWorkingDirectory)\UITools\src\Xamarin.Designer.Android\Xamarin.AndroidDesigner.sln
vsVersion: 17.0
msbuildArgs: /t:Build /p:GitHubToken=$(GitHub.Token)
platform: Any CPU
configuration: DebugWin32

- template: yaml-templates/run-designer-tests.yml
parameters:
designerSourcePath: $(System.DefaultWorkingDirectory)\UITools\src

- stage: bcl_tests
displayName: BCL Emulator Tests
dependsOn: mac_build
Expand Down
1 change: 0 additions & 1 deletion build-tools/installers/create-installers.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<LegacyMSBuildSrcDir>$(XAInstallPrefix)xbuild\Xamarin\Android\</LegacyMSBuildSrcDir>
<MSBuildTargetsSrcDir>$(XamarinAndroidSourcePath)src\Xamarin.Android.Build.Tasks\MSBuild\Xamarin\Android</MSBuildTargetsSrcDir>
<DefaultRuntimeEntitlementsPath>$(MSBuildThisFileDirectory)\..\create-pkg\runtime-entitlements.plist</DefaultRuntimeEntitlementsPath>
<FirstInstallerFrameworkVersion Condition="Exists('$(FrameworkSrcDir)\$(AndroidFirstFrameworkVersion)')">$(AndroidFirstFrameworkVersion)</FirstInstallerFrameworkVersion>
<FirstInstallerFrameworkVersion Condition="'$(FirstInstallerFrameworkVersion)' == ''">$(AndroidLatestStableFrameworkVersion)</FirstInstallerFrameworkVersion>
<BclFrameworkVersion>v1.0</BclFrameworkVersion>
<LibExtension Condition=" '$(HostOS)' == 'Darwin' ">dylib</LibExtension>
Expand Down
4 changes: 2 additions & 2 deletions build-tools/scripts/NUnitReferences.projitems
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project>
<!-- This file assumes Configuration.props has been imported -->
<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit.ConsoleRunner" Version="$(NUnitConsoleVersion)" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
</ItemGroup>
<!-- Required packages for .NET Core -->
<ItemGroup Condition=" '$(TargetFramework)' != 'net472' and '$(TargetFramework)' != 'netstandard2.0' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,17 @@ public override bool Execute ()

var source = cancellationTokenSource = new CancellationTokenSource ();
var tasks = new Task<ITaskItem> [SourceUris.Length];
using (var client = new HttpClient ()) {

// LGTM recommendation
//
// Using HttpClient without providing a platform specific handler (WinHttpHandler or CurlHandler) where the CheckCertificateRevocationList property is set
// to true, will allow revoked certificates to be accepted by the HttpClient as valid.
//
var handler = new HttpClientHandler {
CheckCertificateRevocationList = true,
};

using (var client = new HttpClient (handler)) {
client.Timeout = TimeSpan.FromHours (3);
for (int i = 0; i < SourceUris.Length; ++i) {
tasks [i] = DownloadFile (client, source, SourceUris [i], DestinationFiles [i]);
Expand Down
Loading

0 comments on commit 02b022b

Please sign in to comment.