Skip to content

[Xamarin.Android.Build.Tasks] Remove Android lint support - #13592

Merged
simonrozsival merged 12 commits into
mainfrom
jonathanpeppers-remove-lint-support
Nov 18, 2026
Merged

simonrozsival merged 12 commits into
mainfrom
jonathanpeppers-remove-lint-support

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Context: #13500

$(AndroidLintEnabled) ran the Android SDK lint tool on the generated files in obj/ during packaging. It was off by default, its results pointed at intermediate files instead of the project's sources, and anyone who wants lint can run it from the Android SDK cmdline-tools directly. #13500 proposed rewriting the <Lint/> task as MSBuild targets; removing the feature is less code to maintain.

Removed

  • The <Lint/> task, its unit tests, and the _LintChecks target
  • $(AndroidLintEnabledIssues), $(AndroidLintDisabledIssues), $(AndroidLintCheckIssues), $(LintToolPath), and the @(AndroidLintConfig) item
  • lint discovery in <ResolveAndroidTooling/> and its forwarding to inner builds
  • ResolveSdks.CommandLineToolsPath, which only set $(_AndroidToolsDirectory); nothing read that property
  • The XA0123 and XA5205_Lint resources. XA0102 and XA0103 are no longer emitted; their docs stay, marked as retired.

Compatibility

XA0108 now warns when an app sets $(AndroidLintEnabled) to true:

warning XA0108: The 'AndroidLintEnabled' MSBuild property is no longer supported. Remove it. If needed, run the Android 'lint' tool directly.

The docs for the removed properties and item stay and say they were removed in .NET 12.

Tests

AndroidLintHasNoNewIssues replaces the three lint integration tests. It builds a default app, checks for XA0108, then runs lint --exitcode -Werror from cmdline-tools on the generated manifest, resources, and Java sources. The five checks that fire today (CustomX509TrustManager, HardcodedDebugMode, MissingApplicationIcon, RedundantLabel, UnusedResources) are disabled, so any new lint issue in generated files fails the test.

The tooling-reuse tests used $(LintToolPath) as an escaped path; they now use $(ZipAlignToolPath).

Validation

Built the local SDK on Windows (dotnet-local.cmd build Microsoft.Android.slnx, -t:BuildExtraApiLevels, -t:ConfigureLocalWorkload), then:

dotnet-local.cmd test bin\TestDebug\net11.0\Xamarin.Android.Build.Tests.dll --filter "Name=AndroidLintHasNoNewIssues|Name~ResolvedToolingInputsEscapeApostrophes|Name~ResolveSdks|Name~ResolveAndroidTooling|Name=SdkConsumersUseExplicitPaths|Name~NestedBuildReusesResolvedAndroidTooling|Name~PublishReusesResolvedToolingInSpecializedInnerBuilds"

40 passed, 0 failed. Microsoft.Android.Build.Tasks.Tests builds.

jonathanpeppers and others added 7 commits November 16, 2026 16:16
$(AndroidLintEnabled) ran the Android lint tool on generated files in obj/.
It was off by default and its output did not point to the original source.

Remove the Lint task, the _LintChecks target, the lint properties,
the @(AndroidLintConfig) item, and LintToolPath resolution. Repurpose
XA0108 as a warning when $(AndroidLintEnabled) is true, and remove
XA0102, XA0103, XA0123, and XA5205_Lint.

Co-authored-by: Copilot App <[email protected]>
Build a default app, then run the Android SDK lint tool on the generated
files in obj/. The test disables the checks that fire today and fails on
any new lint issue.

Co-authored-by: Copilot App <[email protected]>
ResolveSdks.CommandLineToolsPath only set _AndroidToolsDirectory, which
nothing reads. Remove it, the AndroidCommandLineToolsVersion SDK input,
and the MonoAndroidHelper.Shared.cs link that only Lint needed.

Use lint --exitcode -Werror in the test and shorten the XA0108 text.

Co-authored-by: Copilot App <[email protected]>
Keep the XA0102 and XA0103 pages marked as retired, like #13407 did.
Disable OldTargetApi in the lint test, because newer installed platforms
trigger it. Restore end-to-end escaping coverage with ZipAlignToolPath.
Remove the fake lint file from test SDKs and the unused environment
parameter of MonoAndroidHelper.RunProcess ().

Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Reusing the XA0108 resource key causes localized builds to display the obsolete lint-version warning instead of removal guidance, so the new message needs a distinct resource key.

1 open issue
1 file not reviewed
  • src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file
What changed in this PR

Removes built-in Android lint support from the .NET for Android build pipeline rather than replacing it with MSBuild targets as proposed in #13500. Users can run the Android SDK lint tool directly.

Changes:

  • Removes the lint task, build integration, tool discovery, and obsolete resources.
  • Adds an XA0108 compatibility warning and documents the removed settings.
  • Replaces lint integration tests with a direct lint check of generated files and updates tooling-reuse tests.
File Description
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Tooling.targets Removes command-line tool resolution and forwarding.
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Common.targets Removes lint integration and adds the compatibility warning.
src/​Xamarin.Android.Build.Tasks/​Utilities/​MonoAndroidHelper.Shared.cs Removes lint-only environment overrides.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.ProjectTools/​Android/​AndroidItem.cs Removes the lint configuration item wrapper.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.ProjectTools/​Android/​AndroidBuildActions.cs Removes the lint build-action constant.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​XASdkTests.cs Uses zipalign paths in tooling-forwarding tests.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Utilities/​BaseTest.cs Supports test process environments and removes fake lint.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​ResolveSdksTaskTests.cs Updates SDK tests for removed lint outputs.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildTest.cs Adds direct lint validation and checks XA0108.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ResolveSdksTask.cs Removes unused command-line tool properties.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ResolveAndroidTooling.cs Removes lint discovery.
src/​Xamarin.Android.Build.Tasks/​Properties/​Resources.resx Updates XA0108 and removes obsolete lint messages.
src/​Xamarin.Android.Build.Tasks/​Properties/​Resources.Designer.cs Synchronizes resource accessors and comments.
src/​Xamarin.Android.Build.Tasks/​MSBuild/​Xamarin/​Android/​Xamarin.Android.AvailableItems.targets Removes the lint configuration build action.
src/​Xamarin.Android.Build.Tasks/​Microsoft.Android.Sdk/​targets/​Microsoft.Android.Sdk.Tooling.targets Removes lint inputs, outputs, and forwarding.
src/​Xamarin.Android.Build.Tasks/​Microsoft.Android.Sdk/​targets/​Microsoft.Android.Sdk.BuildOrder.targets Removes lint from packaging order.
src/​Microsoft.Android.Build.Tasks/​Tests/​Microsoft.Android.Build.Tasks.Tests/​Tasks/​LintTests.cs Deletes lint task unit tests.
src/​Microsoft.Android.Build.Tasks/​Tasks/​Lint.cs Deletes the lint task implementation.
src/​Microsoft.Android.Build.Tasks/​Microsoft.Android.Build.Tasks.csproj Removes the lint-only shared-source link.
src/​Java.Interop.Tools.Diagnostics/​Java.Interop.Tools.Diagnostics/​Diagnostic.cs Removes retired lint diagnostic comments.
Documentation/​docs-mobile/​messages/​xa5205.md Removes the missing-lint example.
Documentation/​docs-mobile/​messages/​xa0108.md Documents the removal warning and migration guidance.
Documentation/​docs-mobile/​messages/​xa0103.md Marks the lint error as retired.
Documentation/​docs-mobile/​messages/​xa0102.md Marks the lint warning as retired.
Documentation/​docs-mobile/​messages/​index.md Updates diagnostic listings and removes the lint task prefix.
Documentation/​docs-mobile/​building-apps/​build-properties.md Marks lint properties as removed in .NET 12.
Documentation/​docs-mobile/​building-apps/​build-items.md Marks AndroidLintConfig as removed in .NET 12.

Review effort: Balanced

jonathanpeppers and others added 3 commits November 17, 2026 09:08
…e-lint-support

# Conflicts:
#	src/Microsoft.Android.Build.Tasks/Microsoft.Android.Build.Tasks.csproj
#	src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs
The localized .resx files still have the old XA0108 text. A new key makes
untranslated cultures fall back to the English message. The diagnostic
code stays XA0108.

Co-authored-by: Copilot App <[email protected]>
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Nov 17, 2026
@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1d4a58ad against main at 14dd230f (merge-base 1c2fe6dc, 28 files). This is a static, read-only review; I did not build or run tests.

Within its own diff the lint removal is complete. Nothing outside the retired docs and generated localization files still references the removed task, properties, item or targets. The new XA0108_LintEnabled resource key fixes the earlier localization concern, and the warning sits in the app-only _CheckNonIdealAppConfigurations like the old _LintChecks did.

Two blockers:

  • Microsoft.Android.Build.Tasks no longer compiles once this merges with current main. #13515 (now on main) moved Aapt2 into Microsoft.Android.Build.Tasks, and src/Microsoft.Android.Build.Tasks/Tasks/Aapt2.cs:26 and :169 call MonoAndroidHelper.ItemGroupToCaseMap and MonoAndroidHelper.FixUpAndroidResourcePath. Both are defined only in MonoAndroidHelper.Shared.cs. This PR deletes that file's compile link from Microsoft.Android.Build.Tasks.csproj (lines 89-90 on main). The hunks don't overlap, so git merges cleanly and the build then fails with CS0117. Please merge main and keep the MonoAndroidHelper.Shared.cs link, rewording its comment to say Aapt2 needs it, or move those two helpers into a file that's already linked.
  • external/android-api-docs is rolled back. The PR moves the submodule from b6c8521e (set on main by #13588) back to 9aeed911, which is 86 commits behind. The earlier merge from main (390c772f57) kept the branch's older pointer, so merging this would silently undo #13588. Please reset it to main's pointer (for example git checkout origin/main -- external/android-api-docs) so it drops out of the diff.

Minor and non-blocking: Resources.Designer.cs loses its UTF-8 BOM on line 1.

jonathanpeppers and others added 2 commits November 17, 2026 15:11
Aapt2 moved into Microsoft.Android.Build.Tasks (#13515) and uses
ItemGroupToCaseMap () and FixUpAndroidResourcePath (), so keep the link.
Reset external/android-api-docs to the commit on main, and restore the
UTF-8 BOM in Resources.Designer.cs.

Co-authored-by: Copilot App <[email protected]>
@simonrozsival
simonrozsival dismissed dalexsoto’s stale review November 18, 2026 10:23

This was already addressed

@simonrozsival
simonrozsival merged commit cca255c into main Nov 18, 2026
38 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers-remove-lint-support branch November 18, 2026 10:24
simonrozsival added a commit that referenced this pull request Nov 21, 2026
The rebase onto cc7cbf6 kept the pre-rebase MSTest conversions of
files that main had changed since aa688ac, which reverted those
changes and broke the build. For each affected file, convert main's
old and new NUnit versions with the same converter and merge the
difference into the MSTest file:

  * cca255c (#13592): drop the Android lint tests and assertions.
  * 5b32fb1 (#13602): add RelativeDirectoriesUseProjectDirectory and
    the -mt CollectNonEmptyDirectories coverage.
  * 78ef747 (#13655): add OpenGenericProxiesKeepTheReflectionActivationConstructor.
  * 18b8940 (#13585): add the generator nullability/obsolete tests.
  * dcbd008 (#13580): add the AmbiguousFunctionMetadata_* tests.
  * 667e27a (#13621): add the sdkmanager package ID tests.
  * 5ecb8f7 (#13614): drop RunWithLoggingEnablesManagedTimingLogger.
  * 8287b17 (#13680), 4bfcc92 (#13681): restore the re-enabled
    tests and removed TODOs.
  * 5d81a0f (#13666): expect platform-tools 37.0.3.
  * 8442c75 (#13601): assert the pulled device TRX is deleted.

Also drop the EnableNUnitRunner/OutputType lines that 857f463
(#13563) added to Xamarin.Android.Build.Tests and MSBuildDeviceIntegration;
MSTestReferences.projitems sets both.

Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants