Welcome to Innominds Blog
Enjoy our insights and engage with us!

Steps to Upload Xamarin Package (Library) to NuGet

By Karthikeya Koppuravuri,
Steps to Upload Xamarin Package to NuGet

Xamarin assists in delivering native Android, iOS, and Windows apps with a single shared .NET code base.

Xamarin tools are available for download on Visual Studio and one can directly create Android, iOS and Windows apps from Visual Studio. Most of the common codes are written in C#; hence, one doesn't need to be well versed in Java, Objective‐ C or Swift to build apps, if they know C#. If you are a beginner, then taking the Xamarin path, instead of the conventional learning process, can equip you to learn app development on various platforms. NuGet An essential tool for any modern development platform, NuGet is a mechanism through which developers can create, share, and consume useful code. More often than not, such code is bundled into "packages" that contain compiled code (as DLLs) along with other content needed in the projects that consume these packages. For .NET (including .NET Core & Xamarin), the Microsoft‐supported mechanism for sharing code is NuGet, which defines how packages for .NET are created, hosted and consumed & provide tools for each of those roles. Put simply, a NuGet package is a single ZIP file with .nupkg extension that contains compiled code (DLLs), other files related to that code, and a descriptive manifest that includes information like the package's version number. Developers with a code to share can create packages and publish them to a public or private host. Package consumers obtain those packages from suitable hosts, add them to their projects and call a package's functionality in their project code. Later, NuGet handles all of the intermediate details. The public repository nuget.org contains many such packages. Detailed Steps to Upload Xamarin Android Package to NuGet

  1. Register for an account with NuGet.org by logging with your Microsoft credentials

  2. In your project, go to the lib folder (ie: ~/<Project Location>/lib)
  3. Create a new lib folder inside (ie: ~/<Project location>/lib/lib)
  4. Create a file with name <ProjectName>.Xamarin.nuspec file into the first lib folder (ie: ~/<Project Locaiton>/lib/<Project Name>.Xamarin.nuspec)
  5. Sample Nupsec content below
    <?xml version="1.0" encoding="utf.8"?>
    <authors>Karthikeya Koppuravuri</authors>
    <owners>Naresh Kumar</owners>
    <description>Sample Desc</description>
    <releaseNotes>https:// github.com/sampleApp/blob/master/README.md</releaseNotes>
    <copyright>Copyright © 2018 CA. All rights reserved</copyright>
    <tags>SampleApp Innominds Xamarin </tags>
    <repository type="git" url="https://github.com/sampleApp/" />
    <dependency id="SampleLib.Xamarin" version="1.0.0" />
  6. Change version number string to the required version
  7. Inside the second lib folder, create two new folders monoandroid and xamarin.ios
  8. Copy the <ProjectName>.IOS.dll into xamarin.ios folder
  9. Open a terminal window at the first lib folder location
  10. Copy the <ProjectName>.Android.dll into the monoandroid folder
  11. Run the command nuget pack <ProjectName>.Xamarin.nuspec (This will create the nupkg file, which will be uploaded to NuGet)
  12. Go to https://www.nuget.org/ and login
  13. At the top of the page, select upload
  14. Select the nupkg file to upload to NuGet.org
  15. If you want this to remain invisible, uncheck the box to appear in search. For more details about uploading nuget packages refer to this
  16. To test install from invisible, navigate to your project and open a terminal window "nuget install <ProjectName>.Xamarin ‐Version 1.0.0" (or whichever the version number is now. This will locally install the package)
  17. Open your project and add the package from your local
  18. To test install from visible, in Visual Studio inside your project, add package from Package Manger and search for <PackageName> ‐> Select latest version and add package

Topics: Mobility

Karthikeya Koppuravuri

Karthikeya Koppuravuri

Karthikeya Koppuravuri - Senior Engineer - Software Engineering

Explore the future of customer support with latest AI! Join us for our upcoming GEN AI webinar on June 25th at 1:00 PM EST. Reserve your spot now!

Subscribe to Email Updates


Show More

Recent Posts