Xamarin Forms Packages Config To Packages Reference

Hello friends, in this article I will talk about how to modernize our old Xamarin projects. Let’s talk about why we need such a thing first. In our old type projects, when we add packages with packages.config, update the packages or throw the packages to git, the size of the project increases and causes version conflicts.

Packages.config works like this; When you install a package, it adds the package to the packages.config file. Each package added to the Packages.config file is downloaded to the packages folder within the project file. For this reason, the dimensions of your projects become too large and increase maintenance costs. The packages you install with PackagesReference are downloaded to a common area, not into the project. In this way, the size of the project does not increase and it uses the previously downloaded packages in other projects without downloading them again. There is also an increase in the project opening time.

For this example, I chose an open source project that we used for the Progress Bar at the time. You can reach the project here.

When you open the project, we will see such a structure.

For this, we first need to make changes in the .csproj section in the Android section. We now specify that this project will restore packages with PackageReference. Then again in this file, as you can see below, the packages; It takes it from the packages folder in the project. Instead, we state that we will now add packages by reference.

After doing these operations, it looks like this.

As a last step, you can delete the packages.config file from the project.

If you want to transfer your project to AndroidX, you can find more detailed information here.

If you have any questions, you can ask by comment or e-mail. Good work.

 

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.