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

[Xamarin.Android.Build.Tasks] set %(DefineConstantsOnly) for older API levels #8777

Merged

Commits on Feb 29, 2024

  1. [Xamarin.Android.Build.Tasks] set %(DefineConstantsOnly) for older …

    …API levels
    
    Fixes: dotnet#8331
    Context: dotnet#8569
    Context: dotnet/sdk@25b360d
    
    Building for `net9.0-android33` would give a poor error message:
    
        error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests.
        C:\Program Files\dotnet\sdk\8.0.100-preview.7.23376.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets
    
    To solve this, you would either change 33 to 34, or just remove the number to rely on the default value.
    
    To make this easier:
    
    * Automatically switch to 34 if the user specifies 33 or less.
    
    * Opt into `%(DefineConstantsOnly)=true` for API levels 21-33 (and not
      the latest), which allows the .NET SDK to emit the *better* .NET SDK
      error message instead.
    
    So now users will get:
    
        (_CheckForInvalidTargetPlatformVersion target) ->
        dotnet/sdk/9.0.100-alpha.1.23628.5/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(243,5):
        error NETSDK1140: 33.0 is not a valid TargetPlatformVersion for Android.
        Valid versions include: 34.0
    
    I added a test for this scenario.
    jonathanpeppers committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    ff2187d View commit details
    Browse the repository at this point in the history