Adding SDK Extension to the Project From a Specific Folder

This article has the goal to expose a sample for adding a SDK Extension to a project from a specific folder.

Motivation

Sometimes developers need to:

  • Manage the SDK Extension in their apps and in some cases they need to keep multiple versions for the same SDK Extension for a different version of the same app
  • Specify the SDK Extension folder for the build process in continuous integration
  • Share samples in the community and to help the users, add the SDK's extension to the project, this way the user doesn´t need to install it

In a real case, the team of Xamarin.Forms.Labs project, created a sample for Windows Phone 8.0. This sample uses the database SQLite  and to help users run the sample, it was associated with the project with the SQLite SDK Extension. With this, the user doesn´t need to install the SQLite SDK Extension in the PC, only build and run the sample.

The solution

When we install the SQLite SDK Extension the installation doesn´t say where the SDK Extension is installed, but it is easy to get the path. For it open/create a Windows Phone project and then select Add reference  > Windows Phone SDK 8.0 and with the mouse over the title of the SDK extension and then it is possible to see the complete path.

sdk extension

Then go to that path and you see something like it.

path

In the project you should create a folder for the SDK Extensions and inside it add a folder with the same tree as we saw before as in the following:

Windows Phone\v8.0\ExtensionsSDKs\SQLite.WP80

For help, we can see the result in the Xamarin.Forms.Labs project:

Xamarin.Forms.Labs project

Note: The folder SDKs were created in the same root as the solution. And if you get the repository then you will see that there is a folder for samples and another for source code  and the solution and SDKs folder are inside the src folder.

After the SDKs folder is created we need to add a configuration to the Windows Phone Project (the project that uses this SDK Extension). In the cproj file add:
  1. <PropertyGroup>  
  2.    <SDKReferenceDirectoryRoot>$(SolutionDir)\Sdks;$(SDKReferenceDirectoryRoot)</SDKReferenceDirectoryRoot>  
  3. </PropertyGroup> 
In Xamarin.Forms.Labs you can find this in the Xamarin.Forms.Labs.Sample.WP.csproj file.

With the solution opened, select the project then select Add reference -> Windows Phone SDK 8.0 and with mouse you can see the path for the SDK Extension.

path for the SDK Extension

Conclusion

In conclusion, adding a especific SDK Extension folder to a project, without installing the SDK Extension in the PC, is very simple and can help to manage the various versions of the SDK Extension and can be useful for building servers with continuous integration.


Similar Articles