AWS Developer Tools Blog

Referencing the AWS SDK for .NET Standard 2.0 from Unity, Xamarin, or UWP

In March 2019, AWS announced support for .NET Standard 2.0 in SDK for .NET. They also announced plans to remove the Portable Class Library (PCL) assemblies from NuGet packages in favor of the .NET Standard 2.0 binaries.

If you’re starting a new project targeting a platform supported by .NET Standard 2.0, especially recent versions of Unity, Xamarin and UWP, you may want to use the .NET Standard 2.0 assemblies for the AWS SDK instead of the PCL assemblies.

Currently, it’s challenging to consume .NET Standard 2.0 assemblies from NuGet packages directly in your PCL, Xamarin, or UWP applications. Unfortunately, the new csproj file format and NuGet don’t let you select assemblies for a specific target framework (in this case, .NET Standard 2.0). This limitation can cause problems because NuGet always restores the assemblies for the target framework of the project being built (in this case, one of the legacy PCL assemblies).

Considering this limitation, our guidance is for your application to directly reference the AWS SDK assemblies (DLL files) which can be downloaded as a .zip file from here. Every version of the SDK assemblies is also archived and available at a URI like http://sdk-for-net.amazonwebservices.com/releases/aws-sdk-netstandard2.0-3.3.597.0.zip.

When using Unity (2018.1 or newer), choose .NET 4.x Equivalent as Scripting Runtime Version and copy the AWS SDK for .NET assemblies into the Asset folder.

If you are using IL2CPP to build your Unity project, you must add a link.xml file to your Asset folder to prevent code stripping in the AWSSDK assemblies. The link.xml file must list all the AWSSDK assemblies you are using and must be marked with the preserve=”all” attribute. The file should look like this:

<linker>
       <assembly fullname="AWSSDK.Core" preserve="all"/>

       <assembly fullname="AWSSDK.DynamoDBv2" preserve="all"/>

       <assembly fullname="AWSSDK.Lambda" preserve="all"/>

</linker>

More information about IL2CPP and the link.xml file can be found in the Unity documentation.

At this time, not all features specific to the PCL and Unity SDK libraries have been ported over to .NET Standard 2.0. To suggest features, changes, or leave other feedback to make PCL and Unity development easier, open an issue on our aws-sdk-net-issues GitHub repo.

Consuming the assemblies from the .zip files will only be needed until PCL assemblies are removed from the NuGet packages. At that time, restoring the NuGet packages from an iOS, Android or UWP project (either a Xamarin or Unity project) should result in the .NET Standard 2.0 assemblies being referenced and included in your build outputs.