-
Notifications
You must be signed in to change notification settings - Fork 564
[Xamarin.Android.Build.Utilities] Add AndroidVersions #599
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
Conversation
be66d1a to
067d133
Compare
| { | ||
| public class AndroidVersion | ||
| { | ||
| [Obsolete ("Use AndroidVersions.MaxVersion.ApiLevel", error:true)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...which doesn't exist. Oops.
Anyway, it's not used in this project, due to error:true. Do we really need to track MaxApiLevel?
|
Excellent. Now the question is how do we propagate that to the IDEs. I see two options:
Both approach have pro and cons, first might be easier to implement for now though |
That's an interesting idea, but if we went for the MSBuild-specific approach, why bother with half of this code at all? We could provide (That might not be a bad idea, actually. More thought is required.) As for the integration idea, there is already (kinda, sorta) a plan (-ish) for that: xamarin-android-tools, which is kinda/sorta the "open-source" parts of However, I want to do some API cleanups ("breaks"!) as part of this, which is a discussion for another time. It's basically the only time we can do such cleanups, as it would be in a new assembly... |
|
I don't think it really make sense to get this info though MSBuild calls since it doesn't depend on the state of the project at all. |
|
The problem in macOS+xbuild PR Build 952 is our old nemesis, xbuild, which looks at Since the system-wide directory is used here -- a directory which does not, cannot, contain the new There are two plausible fixes that bear investigation:
|
3bf9f56 to
95eab39
Compare
|
Next in our comedy of "ow! make it stop!", using Fix that issue by improving (Back and forth we swing!) The most recent failure is "fun": the For context, (Hacking At this point, I'm not sure how to fix this, much less elegantly fix this, short of "kill xbuild, msbuild all the things!" Which, to be fair, is looking really appealing right now... |
95eab39 to
9c8925a
Compare
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ``` <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Deprecate all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
9c8925a to
cd7da91
Compare
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ``` <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
cd7da91 to
8728168
Compare
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ``` <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
| <Name>O Preview</Name> | ||
| <Level>26</Level> | ||
| <Id>O</Id> | ||
| <Stable>False</Stable> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably change this to True...
8728168 to
570bcda
Compare
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ``` <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
570bcda to
e77f581
Compare
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ``` <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
e77f581 to
54316cf
Compare
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ``` <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
54316cf to
4c26e75
Compare
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ``` <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
4c26e75 to
51d213c
Compare
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ``` <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
51d213c to
2644e1d
Compare
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ``` <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
2644e1d to
4365424
Compare
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ``` <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
4365424 to
5f003ce
Compare
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ```xml <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
5f003ce to
b4d8733
Compare
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ```xml <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
| int vn; | ||
| if (!int.TryParse (version, out vn)) | ||
| vn = AndroidVersion.MaxApiLevel; | ||
| return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonpryor should we be returning null here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this should be AndroidVersions. MaxStableVersion ?
| <_Line Include="@(_ApiInfo->' <Stable>%(Stable)</Stable>')" /> | ||
| <_Line Include="</AndroidApiInfo>" /> | ||
| </ItemGroup> | ||
| <Message Text="# jonp: _Line=@(_Line)" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonpryor can we remove the debug message :)
dellis1972
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of changes needed. see comments
b4d8733 to
4321044
Compare
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ```xml <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ```xml <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build dotnet#503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: dotnet#599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
4321044 to
e3b64af
Compare
Commit 8942eca [broke the build][xa554]: [xa554]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/554/ error XA0000: Could not determine $(TargetFrameworkVersion) for API level '26.' The cause of the failure is that we're using `xbuild` within the `make leeroy-all` target, but [we need to use `xabuild`][xbuild-paths]: [xbuild-paths]: #599 (comment) Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" `xbuild` is trying to use the *system-wide* `/Library/Frameworks/Mono.framework/External/xbuild-frameworks` directory, which *cannot* contain the now-required `AndroidApiInfo.xml` files which are needed for probing. Fix the `make leeroy-all` target to use `$(_SLN_BUILD)`, just as the `make all` target does, so that the correct paths are used.
Changes: dotnet/java-interop@27cfd45...bd7c60a * dotnet/java-interop@bd7c60a: [generator] Support //interface/@no-alternatives (#601) * dotnet/java-interop@105d544: [generator] Remove interface alternatives w/ interface-constants (#600) * dotnet/java-interop@b255981: [build] Remove extraneous `nuget restore`s (#599) * dotnet/java-interop@2a59c40: [CI] Specify our PR build trigger in YAML. (#598) * dotnet/java-interop@0a3354b: [Java.Interop.Tools.Cecil] use File.Exists instead of DirectoryGetFile (#596) Reduces the `<LinkAssembliesNoShrink/>` task time from about 711ms to 426ms for a small test Xamarin.Forms app on an initial clean build. Updates `generator --lang-features=interface-constants` output so that we stop emitting the `*Consts` classes in API-R. API Breakages: * `tests/api-compatibility/acceptable-breakages-v10.0.99.txt`: These are because we are no longer generating the `*Consts` types when for Default Interface Methods are enabled. * `tests/api-compatibility/acceptable-breakages-v10.0.txt`: These are because there was a bug where we were not generating `[Obsolete]` on fields that were turned into properties. Now the attribute is generated in API-28 (the "contract"), but they are no longer marked as deprecated by Google in API-29 (the "implementation"), so they appear as removing the attribute. * `tests/api-compatibility/acceptable-breakages-v8.0.txt`: As with v10.0, a "prop-ified" field was missing `[Obsolete]`, and Google later un-deprecated the field.
Commit 8e7d37b is a sign of duplication: in order to use a
Mono.Android.dllbinding assembly, not only do we need to buildthe binding assembly, but we also need to update
Xamarin.Android.Build.Utilities.dllto "know" about the new bindingversion (to map API level to
$(TargetFrameworkVersion)).Even "better" (worse), if the new API level is a preview, there is
no consistent API level. For example, with API-O,
android.jarisn't at
$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar,where
@API_LEVEL@is 26 (because various codepaths require that the"api level" be an integer). Instead, it's installed at
$(AndroidSdkDirectory)\platforms\android-O\android.jar, whereOis the "id" of the preview API level.This "id" is "leaky", in turn requiring that
Xamarin.Android.Build.Tasks.dllalso be updated to deal with themappings.
Even "better" (worse), if we forget to cross all our our 't's and
dot all of our 'i's, we'll have a binding assembly which can't be
used. (Which is why we needed commit 8e7d37b; without it, the API-O
binding can't be used!)
This is all obviously madness. ;-)
Clean this mess up:
Update
src/Mono.Androidto create a newAndroidApiInfo.xmlfile within the
$(TargetFrameworkDriectory)directory.This will contain all the information needed to map Android API
levels to Ids and Android OS versions and
$(TargetFrameworkVersion)values.Add a new
Xamarin.Android.Build.Utilities.AndroidVersionstypewhich looks for and parses these new
AndroidApiInfo.xmlfiles.Fixup all the other places using
AndroidVersion.KnownVersionsand related members to instead use
AndroidVersions.Deprecate all the old APIs which rely on hardcoded data.
The advantage to all this is that we can support new API level
bindings by just building a new
Mono.Android.dlland placing anAndroidApiInfo.xmlinto the appropriate location (next toMono.Android.dll). No further code changes would be required.