diff --git a/Documentation/guides/OneDotNet.md b/Documentation/guides/OneDotNet.md index d9e7e8b6c8e..27e1d728500 100644 --- a/Documentation/guides/OneDotNet.md +++ b/Documentation/guides/OneDotNet.md @@ -29,22 +29,28 @@ project][binding] as a separate project type. Any of the MSBuild item groups or build actions that currently work in binding projects will be supported through a .NET 6 Android application or library. -For example, a binding library could look like: +For example, a binding library would be identical to a class library: ```xml net6.0-android - - - - ``` +Along with the file structure: + + Transforms/ + Metadata.xml + foo.jar + +`Transforms\*.xml` files are automatically included as a +`@(TransformFile)` item, and `.jar` files are automatically included +as a `@(AndroidLibrary)` item. + This will bind C# types for the Java types found in `foo.jar` using -the metadata fixups from `Metadata.xml`. +the metadata fixups from `Transforms\Metadata.xml`. [binding]: https://docs.microsoft.com/xamarin/android/platform/binding-java-library/ diff --git a/Documentation/guides/OneDotNetEmbeddedResources.md b/Documentation/guides/OneDotNetEmbeddedResources.md index eaf94750f9a..8d9a2343863 100644 --- a/Documentation/guides/OneDotNetEmbeddedResources.md +++ b/Documentation/guides/OneDotNetEmbeddedResources.md @@ -179,15 +179,15 @@ Let's simplify this, we could support all of the above with a new ```xml - + - - + + - + @@ -195,9 +195,9 @@ Let's simplify this, we could support all of the above with a new The new `@(AndroidLibrary)` item group will simply translate to the old ones for backwards compatibility. The extension of the file can be -used to determine what kind of library each item is. `%(Bind)` will be -`false` by default, and `%(Pack)` will be `true` by default. `%(Pack)` -will not do anything in application projects. +used to determine what kind of library each item is. `%(Bind)` and +`%(Pack)` will both be `true` by default. `%(Pack)` will not do +anything in application projects. The deprecated item groups will no longer embed, but pack into `.nupkg` files instead: diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/Sdk/AutoImport.props b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/Sdk/AutoImport.props index 42ccfa9744b..0a417097111 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/Sdk/AutoImport.props +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/Sdk/AutoImport.props @@ -16,9 +16,9 @@ https://github.com/dotnet/designs/blob/4703666296f5e59964961464c25807c727282cae/ --> - - + + @@ -28,11 +28,14 @@ https://github.com/dotnet/designs/blob/4703666296f5e59964961464c25807c727282cae/ - - - - + + + + + + + diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AndroidLibraries.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AndroidLibraries.targets index e8fdcd05fb7..7b72962351b 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AndroidLibraries.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AndroidLibraries.targets @@ -18,7 +18,7 @@ projects. - false + true true diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs index bec46cd6cf1..dfbe56820a0 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs @@ -259,8 +259,13 @@ public void DotNetLibraryAarChanges () public void DotNetBuildBinding () { var proj = new XASdkProject (outputType: "Library"); - proj.OtherBuildItems.Add (new AndroidItem.AndroidLibrary ("javaclasses.jar") { - MetadataValues = "Bind=true", + proj.Sources.Add (new AndroidItem.TransformFile ("Transforms\\Metadata.xml") { + TextContent = () => +@" + MSBuildTest +", + }); + proj.Sources.Add (new AndroidItem.AndroidLibrary ("javaclasses.jar") { BinaryContent = () => Convert.FromBase64String (InlineData.JavaClassesJarBase64) }); // TODO: bring back when Xamarin.Android.Bindings.Documentation.targets is working @@ -273,7 +278,7 @@ public void DotNetBuildBinding () var assemblyPath = Path.Combine (FullProjectDirectory, proj.OutputPath, "UnnamedProject.dll"); FileAssert.Exists (assemblyPath); using (var assembly = AssemblyDefinition.ReadAssembly (assemblyPath)) { - var typeName = "Com.Xamarin.Android.Test.Msbuildtest.JavaSourceJarTest"; + var typeName = "MSBuildTest.JavaSourceJarTest"; var type = assembly.MainModule.GetType (typeName); Assert.IsNotNull (type, $"{assemblyPath} should contain {typeName}"); }