forked from dotnet/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[One .NET] fix $(PackageTargetFallback) and $(TargetPlatformVersion) (d…
…otnet#5835) Fixes: dotnet#5819 A project using Maui and `TargetFramework=net6.0-android` can hit the warning: warning CA1416: This call site is reachable on all platforms. 'Class1' is only supported on: 'android' 30.0 and later. I found the project had: TargetPlatformVersion = 30 Projects that emit no warnings have `TargetPlatformVersion = 30.0`. Update the `<GenerateSupportedPlatforms/>` MSBuild task to always append `.0`: version.ApiLevel.ToString ("0.0", CultureInfo.InvariantCulture) This solves the warning, but we still get an error in other projects in the solution: error CS1061: 'Class1<TVirtualView, TNativeView>' does not contain a definition for 'Context' and no accessible extension method 'Context' accepting a first argument of type 'Class1<TVirtualView, TNativeView>' could be found (are you missing a using directive or an assembly reference?) The build used: ~\.nuget\packages\microsoft.maui.core\6.0.100-preview.3.269\lib\netstandard2.1\Microsoft.Maui.dll Instead of: ~\.nuget\packages\microsoft.maui.core\6.0.100-preview.3.269\lib\net6.0-android30.0\Microsoft.Maui.dll I found this project uses `TargetFramework=net6.0-android30.0`, which resulted in a weird value for `$(PackageTargetFallback)`: PackageTargetFallback = net6.0-android30.0.0; monoandroid12.0; monoandroid11.0; monoandroid10.0; monoandroid90; monoandroid81; monoandroid80; monoandroid70; monoandroid60; monoandroid50; To fix this, I conditionally added the `.0` and the project builds successfully. We will hopefully be able to remove usage of `$(PackageTargetFallback)` soon, as it was a workaround until NuGet has official support for .NET 6 & MonoAndroid target frameworks. I added a new test that covers these cases. I also added a new `AssertHasNoWarnings()` extension method to simplify checking for warnings. I also updated a couple tests that no longer emit warnings.
- Loading branch information
1 parent
522d7fb
commit b36df8f
Showing
6 changed files
with
62 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters