All Projects → xamarin → Xamarin.Legacy.Sdk

xamarin / Xamarin.Legacy.Sdk

Licence: MIT license
Starting from a .NET 6 project, adds the ability to target legacy Xamarin target frameworks such as monoandroid11.0 or xamarin.ios10. *Not fully supported*

Projects that are alternatives of or similar to Xamarin.Legacy.Sdk

Metal2-Samples
A Metal Sample Gallery written in CSharp using NET6
Stars: ✭ 25 (+38.89%)
Mutual labels:  net6
msbuild-flame-graph
Turns MSBuild executions into flame graphs
Stars: ✭ 37 (+105.56%)
Mutual labels:  msbuild
Phenix.NET7
Phenix Framework 7 for .NET 6
Stars: ✭ 31 (+72.22%)
Mutual labels:  net6
vsSolutionBuildEvent
🎛 Event-Catcher with variety of advanced Actions to service projects, libraries, build processes, runtime environment of the Visual Studio, MSBuild Tools, and …
Stars: ✭ 66 (+266.67%)
Mutual labels:  msbuild
Vortice.Vulkan
Cross platform .NET bindings for Vulkan, VMA, SPIRV-Cross and shaderc
Stars: ✭ 172 (+855.56%)
Mutual labels:  net6
Get-EventSession
Script to assist in downloading Microsoft event contents or return session information.
Stars: ✭ 55 (+205.56%)
Mutual labels:  msbuild
kontent-boilerplate-net
Kontent.ai Boilerplate for development of ASP.NET Core MVC applications.
Stars: ✭ 29 (+61.11%)
Mutual labels:  net6
PowerBuild
Integrate MSBuild into PowerShell pipeline.
Stars: ✭ 24 (+33.33%)
Mutual labels:  msbuild
MvsSln
🧩 Customizable VisualStudio .sln parser, Complex support of the projects (.vcxproj, .csproj., …), Pluginable lightweight r/w handlers at runtime, and more …
Stars: ✭ 86 (+377.78%)
Mutual labels:  msbuild
vkm
VK music downloader
Stars: ✭ 14 (-22.22%)
Mutual labels:  msbuild
CodeContracts.MSBuild
Standalone MSBuild integration of CodeContracts (by Microsoft Research)
Stars: ✭ 16 (-11.11%)
Mutual labels:  msbuild
GmodDotNet
Cross-platform .NET Module/Plugin platform for Garry's Mod powered by .NET.
Stars: ✭ 62 (+244.44%)
Mutual labels:  net6
MoltenEngine
A spare-time C# .NET 6 game engine project. Cross-platform, multi-threaded.
Stars: ✭ 113 (+527.78%)
Mutual labels:  net6
Examples
An complete examples and related support for various popular projects, and more.
Stars: ✭ 22 (+22.22%)
Mutual labels:  msbuild
SimpleGitVersion
Simple Git prerelease versioning integrated into SDK-based msbuild projects
Stars: ✭ 17 (-5.56%)
Mutual labels:  msbuild
UnityAssemblies
Simple, forward-compatible references to ANY Unity DLL on ANY platform.
Stars: ✭ 65 (+261.11%)
Mutual labels:  msbuild
EmptyLicensesLicx
Easy continuous integration of apps using third-party controls that rely on licenses.licx files
Stars: ✭ 57 (+216.67%)
Mutual labels:  msbuild
gradle-msbuild-plugin
Gradle plugin for msbuild execution, supports C# project files for now
Stars: ✭ 101 (+461.11%)
Mutual labels:  msbuild
TSLint.MSBuild
[Deprecated] An MSBuild task for running TSLint.
Stars: ✭ 13 (-27.78%)
Mutual labels:  msbuild
vortice
Cross-platform .NET 6.0 game engine.
Stars: ✭ 210 (+1066.67%)
Mutual labels:  net6

Xamarin.Legacy.Sdk

Starting from a .NET 6 project, adds the ability to target legacy Xamarin target frameworks such as monoandroid11.0 or xamarin.ios10. Not fully supported.

What is this? When would I need it?

You only need Xamarin.Legacy.Sdk if you have a NuGet package that needs to target "legacy" Xamarin and .NET 6 at the same time.

NOTE: If you are looking for general information about Xamarin and .NET 6. You might start with the dotnet/net6-mobile-samples Github repository instead.

Xamarin components like AndroidX or Google Play Services are prime examples that need to use Xamarin.Legacy.Sdk.

For example, the current Xamarin.AndroidX.AppCompat.nupkg includes:

  • lib\monoandroid90\
    • Xamarin.AndroidX.AppCompat.dll

Note that the monoandroid90 assembly might work in .NET 6. Failures could certainly happen at runtime, due to using a completely different BCL. Using legacy Xamarin packages also brings some compatibility baggage along with it. For example, Xamarin.AndroidX.AppCompat.dll will have a reference to mscorlib.dll. mscorlib.dll does not exist in .NET 6, and types in mscorlib.dll are forwarded to the appropriate .NET 6 BCL assembly. The way for Xamarin.AndroidX.AppCompat.dll to fully support .NET 6 is to actually be compiled against .NET 6.

If the package needs to continue shipping monoandroid90 but also include full support for .NET 6, the package could include additional target frameworks:

  • lib\monoandroid90\
    • Xamarin.AndroidX.AppCompat.dll
  • lib\net6.0-android30.0\
    • Xamarin.AndroidX.AppCompat.dll

Previously, there was not a "nice" way to produce the above package. It would involve multiple .csproj files and a .nuspec that combines the files together.

Xamarin.Legacy.Sdk solves this problem by:

  • Starting with a .NET 6 project that produces a net6.0 class library -- built via dotnet build.
  • Using Xamarin.Legacy.Sdk allows the .NET 6 project to add additional $(TargetFrameworks) such as monoandroid11.0 or xamarin.ios10.
  • This effectively imports Xamarin.Android/iOS.CSharp.targets running the existing Xamarin MSBuild tasks & targets under dotnet build.

Getting started

Xamarin.Legacy.Sdk allows you to create a class library such as:

<Project Sdk="Xamarin.Legacy.Sdk">
  <PropertyGroup>
    <TargetFrameworks>monoandroid11.0;xamarin.ios10;net6.0-android;net6.0-ios</TargetFrameworks>
  </PropertyGroup>
</Project>

You will also need either include a global.json with:

{
  "msbuild-sdks": {
    "Xamarin.Legacy.Sdk": "0.1.0-alpha2"
  }
}

Or specify the version inline:

<Project Sdk="Xamarin.Legacy.Sdk/0.1.0-alpha2">

To setup a binding project instead of a class library, simply set <IsBindingProject>true</IsBindingProject> in your .csproj file.

What about MSBuild.Sdk.Extras?

We considered adding to MSBuild.Sdk.Extras, however, a few things would make this story... complicated.

Xamarin.Legacy.Sdk emulates all behavior of .NET 6. This means all MSBuild defaults will be applied, such as:

This would certainly introduce breaking changes to MSBuild.Sdk.Extras.

Samples

  • Hello: a simple class library targeting Xamarin.iOS, Xamarin.Android, and .NET 6
  • JavaBinding: a Xamarin.Android binding for com.google.code.gson based off of the GoogleGson Xamarin component.

Installation requirements

You will need:

  • .NET 6 SDKs and any other dependencies as described by the .NET 6 samples repo.
  • At least Visual Studio 2019 16.9 Preview 4 or higher for IDE support for .NET 6.
  • The Xamarin workload from the Visual Studio installer.

NOTE: that at least Xamarin.Android 11.2.99.43 is needed for Java bindings, which is a nightly build.

View azure-pipelines.yml for known good builds and download links.

Troubleshooting

Notes for Windows

dotnet build command-line with .NET 6 will have a new enough MSBuild for this to work.

Otherwise, you will at least need Visual Studio 2019 16.9 which is currently in preview to use:

> "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\MSBuild.exe" -version

You will also need to enable a feature-flag to enable .NET 6 workloads. In an administrator command prompt:

cd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\SdkResolvers\Microsoft.DotNet.MSBuildSdkResolver"
echo > EnableWorkloadResolver.sentinel

This will create an empty file.

Microsoft.Android.Sdk not installed

If you hit the error:

The following workload packs were not installed: Microsoft.Android.Sdk

Temporarily, you can make a symbolic link to workaround this. In an administrator command prompt:

> mklink /J "C:\Program Files\dotnet\packs\Microsoft.Android.Sdk" "C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.win-x64"
Junction created for C:\Program Files\dotnet\packs\Microsoft.Android.Sdk <<===>> C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.win-x64

This workaround should no longer be needed when the MSBuild shipped in Visual Studio is updated.

Notes for macOS

The version of MSBuild shipped with Mono & VS for Mac is not currently new enough to build .NET 6 projects. For now, you will need to use dotnet build at the command-line.

If you hit the error:

error : /usr/local/share/dotnet/sdk/6.0.100-alpha.1.20562.2/Sdks/Microsoft.Android.Sdk/Sdk not found. Check that a recent enough .NET SDK is installed and/or increase the version specified in global.json.

Verify you are using dotnet build have the required .NET 6 packages installed.

libMonoPosixHelper.dylib

If you hit the error:

error XACML7000: System.DllNotFoundException: Unable to load shared library 'MonoPosixHelper' or one of its dependencies.
In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libMonoPosixHelper, 1): image not found 

A temporary workaround would be:

$ cd /Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/xbuild/Xamarin/Android/lib/host-Darwin/
$ sudo cp libMonoPosixHelper.dylib ../../

This simply copies libMonoPosixHelper.dylib to an additional location so it can be loaded when running under .NET 6.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].