{"id":1862,"date":"2021-01-13T11:14:34","date_gmt":"2021-01-13T11:14:34","guid":{"rendered":"https:\/\/sezeromer.com\/?p=1862"},"modified":"2023-03-04T13:27:13","modified_gmt":"2023-03-04T10:27:13","slug":"xamarin-forms-packages-config-to-packages-reference","status":"publish","type":"post","link":"https:\/\/sezeromer.com\/en\/xamarin-forms-packages-config-to-packages-reference\/","title":{"rendered":"Xamarin Forms Packages Config To Packages Reference"},"content":{"rendered":"<p>Hello friends, in this article I will talk about how to modernize our old <strong>Xamarin<\/strong> projects. Let&#8217;s talk about why we need such a thing first. In our old type projects, when we add packages with <strong>packages.config<\/strong>, update the packages or throw the packages to git, the size of the project increases and causes version conflicts.<\/p>\n<p><strong>Packages.config<\/strong> 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.<\/p>\n<p>For this example, I chose an open source project that we used for the Progress Bar at the time. You can reach the project <a href=\"https:\/\/github.com\/jamesmontemagno\/Xamarin.Forms-Android-CustomProgressBar\">here<\/a>.<\/p>\n<p>When you open the project, we will see such a structure.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1979\" src=\"https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.32.00-1024x556.png\" alt=\"\" width=\"640\" height=\"348\" srcset=\"https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.32.00-1024x556.png 1024w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.32.00-300x163.png 300w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.32.00-768x417.png 768w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.32.00-500x272.png 500w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.32.00-800x435.png 800w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.32.00-1280x695.png 1280w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.32.00-1920x1043.png 1920w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.32.00-1536x835.png 1536w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.32.00-2048x1113.png 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>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.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1980\" src=\"https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.54.52-1024x651.png\" alt=\"\" width=\"640\" height=\"407\" srcset=\"https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.54.52-1024x651.png 1024w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.54.52-300x191.png 300w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.54.52-768x488.png 768w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.54.52-500x318.png 500w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.54.52-800x509.png 800w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.54.52-1280x814.png 1280w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.54.52-1536x977.png 1536w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-13.54.52.png 1552w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>After doing these operations, it looks like this.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1981\" src=\"https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-14.09.13-1024x556.png\" alt=\"\" width=\"640\" height=\"348\" srcset=\"https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-14.09.13-1024x556.png 1024w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-14.09.13-300x163.png 300w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-14.09.13-768x417.png 768w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-14.09.13-500x272.png 500w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-14.09.13-800x435.png 800w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-14.09.13-1280x695.png 1280w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-14.09.13-1920x1043.png 1920w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-14.09.13-1536x835.png 1536w, https:\/\/sezeromer.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-2021-01-13-at-14.09.13-2048x1113.png 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;swift&quot;,&quot;mime&quot;:&quot;text\/x-swift&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:true,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http:\/\/schemas.microsoft.com\/developer\/msbuild\/2003\"&gt;\r\n  &lt;PropertyGroup&gt;\r\n    &lt;Configuration Condition=\" '$(Configuration)' == '' \"&gt;Debug&lt;\/Configuration&gt;\r\n    &lt;Platform Condition=\" '$(Platform)' == '' \"&gt;AnyCPU&lt;\/Platform&gt;\r\n    &lt;ProjectTypeGuids&gt;{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}&lt;\/ProjectTypeGuids&gt;\r\n    &lt;ProjectGuid&gt;{2B700BAB-5304-4AC1-8321-6F68578D9459}&lt;\/ProjectGuid&gt;\r\n    &lt;OutputType&gt;Library&lt;\/OutputType&gt;\r\n    &lt;RootNamespace&gt;CustomProgressBar.Droid&lt;\/RootNamespace&gt;\r\n    &lt;MonoAndroidAssetsPrefix&gt;Assets&lt;\/MonoAndroidAssetsPrefix&gt;\r\n    &lt;MonoAndroidResourcePrefix&gt;Resources&lt;\/MonoAndroidResourcePrefix&gt;\r\n    &lt;AndroidResgenClass&gt;Resource&lt;\/AndroidResgenClass&gt;\r\n    &lt;AndroidResgenFile&gt;Resources\\Resource.designer.cs&lt;\/AndroidResgenFile&gt;\r\n    &lt;AndroidApplication&gt;True&lt;\/AndroidApplication&gt;\r\n    &lt;AssemblyName&gt;CustomProgressBar.Droid&lt;\/AssemblyName&gt;\r\n    &lt;TargetFrameworkVersion&gt;v6.0&lt;\/TargetFrameworkVersion&gt;\r\n    &lt;AndroidManifest&gt;Properties\\AndroidManifest.xml&lt;\/AndroidManifest&gt;\r\n    &lt;NuGetPackageImportStamp&gt;\r\n    &lt;\/NuGetPackageImportStamp&gt;\r\n  &lt;\/PropertyGroup&gt;\r\n  &lt;PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \"&gt;\r\n    &lt;DebugSymbols&gt;true&lt;\/DebugSymbols&gt;\r\n    &lt;DebugType&gt;full&lt;\/DebugType&gt;\r\n    &lt;Optimize&gt;false&lt;\/Optimize&gt;\r\n    &lt;OutputPath&gt;bin\\Debug&lt;\/OutputPath&gt;\r\n    &lt;DefineConstants&gt;DEBUG;&lt;\/DefineConstants&gt;\r\n    &lt;ErrorReport&gt;prompt&lt;\/ErrorReport&gt;\r\n    &lt;WarningLevel&gt;4&lt;\/WarningLevel&gt;\r\n    &lt;AndroidLinkMode&gt;None&lt;\/AndroidLinkMode&gt;\r\n    &lt;ConsolePause&gt;false&lt;\/ConsolePause&gt;\r\n  &lt;\/PropertyGroup&gt;\r\n  &lt;PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' \"&gt;\r\n    &lt;DebugType&gt;full&lt;\/DebugType&gt;\r\n    &lt;Optimize&gt;true&lt;\/Optimize&gt;\r\n    &lt;OutputPath&gt;bin\\Release&lt;\/OutputPath&gt;\r\n    &lt;ErrorReport&gt;prompt&lt;\/ErrorReport&gt;\r\n    &lt;WarningLevel&gt;4&lt;\/WarningLevel&gt;\r\n    &lt;AndroidUseSharedRuntime&gt;false&lt;\/AndroidUseSharedRuntime&gt;\r\n    &lt;ConsolePause&gt;false&lt;\/ConsolePause&gt;\r\n  &lt;\/PropertyGroup&gt;\r\n  \r\n  &lt;PropertyGroup&gt;\r\n    &lt;RestoreProjectStyle&gt;PackageReference&lt;\/RestoreProjectStyle&gt;\r\n  &lt;\/PropertyGroup&gt;\r\n\r\n  &lt;ItemGroup&gt;\r\n      &lt;PackageReference Include=\"MonoDroid.Toolkit\" Version=\"1.1.0.0\" \/&gt;\r\n      &lt;PackageReference Include=\"Xamarin.Android.Support.Animated.Vector.Drawable\" Version=\"23.3.0\" \/&gt;\r\n      &lt;PackageReference Include=\"Xamarin.Android.Support.Design\" Version=\"23.3.0\" \/&gt;\r\n      &lt;PackageReference Include=\"Xamarin.Android.Support.v4\" Version=\"23.3.0\" \/&gt;\r\n      &lt;PackageReference Include=\"Xamarin.Android.Support.v7.AppCompat\" Version=\"23.3.0\" \/&gt;\r\n      &lt;PackageReference Include=\"Xamarin.Android.Support.v7.CardView\" Version=\"23.3.0\" \/&gt;\r\n      &lt;PackageReference Include=\"Xamarin.Android.Support.v7.MediaRouter\" Version=\"23.3.0\" \/&gt;\r\n      &lt;PackageReference Include=\"Xamarin.Android.Support.v7.RecyclerView\" Version=\"23.3.0\" \/&gt;\r\n      &lt;PackageReference Include=\"Xamarin.Android.Support.Vector.Drawable\" Version=\"23.3.0\" \/&gt;\r\n      &lt;PackageReference Include=\"Xamarin.Forms\" Version=\"2.3.3.180\" \/&gt;\r\n    &lt;\/ItemGroup&gt;\r\n\r\n  &lt;ItemGroup&gt;\r\n    &lt;Reference Include=\"System\" \/&gt;\r\n    &lt;Reference Include=\"System.Xml\" \/&gt;\r\n    &lt;Reference Include=\"System.Core\" \/&gt;\r\n    &lt;Reference Include=\"Mono.Android\" \/&gt;\r\n    &lt;Reference Include=\"System.Windows\" \/&gt;\r\n  &lt;\/ItemGroup&gt;\r\n\r\n  &lt;ItemGroup&gt;\r\n    &lt;Compile Include=\"MainActivity.cs\" \/&gt;\r\n    &lt;Compile Include=\"Resources\\Resource.designer.cs\" \/&gt;\r\n    &lt;Compile Include=\"Properties\\AssemblyInfo.cs\" \/&gt;\r\n    &lt;Compile Include=\"Renderers\\CircularProgressRenderer.cs\" \/&gt;\r\n  &lt;\/ItemGroup&gt;\r\n  &lt;ItemGroup&gt;\r\n    &lt;None Include=\"Resources\\AboutResources.txt\" \/&gt;\r\n    &lt;None Include=\"Assets\\AboutAssets.txt\" \/&gt;\r\n    &lt;None Include=\"Properties\\AndroidManifest.xml\" \/&gt;\r\n  &lt;\/ItemGroup&gt;\r\n  &lt;ItemGroup&gt;\r\n    &lt;AndroidResource Include=\"Resources\\layout\\Main.axml\" \/&gt;\r\n    &lt;AndroidResource Include=\"Resources\\values\\Strings.xml\" \/&gt;\r\n    &lt;AndroidResource Include=\"Resources\\drawable\\Icon.png\" \/&gt;\r\n  &lt;\/ItemGroup&gt;\r\n  &lt;Import Project=\"$(MSBuildExtensionsPath)\\Xamarin\\Android\\Xamarin.Android.CSharp.targets\" \/&gt;\r\n  &lt;ItemGroup \/&gt;\r\n  &lt;ItemGroup&gt;\r\n    &lt;ProjectReference Include=\"..\\CustomProgressBar.Portable\\CustomProgressBar.Portable.csproj\"&gt;\r\n      &lt;Project&gt;{BCBDC8BF-157E-450D-8B1E-4CBF49A81EDA}&lt;\/Project&gt;\r\n      &lt;Name&gt;CustomProgressBar.Portable&lt;\/Name&gt;\r\n    &lt;\/ProjectReference&gt;\r\n  &lt;\/ItemGroup&gt;\r\n  &lt;Import Project=\"..\\packages\\Xamarin.Android.Support.Vector.Drawable.23.3.0\\build\\Xamarin.Android.Support.Vector.Drawable.targets\" Condition=\"Exists('..\\packages\\Xamarin.Android.Support.Vector.Drawable.23.3.0\\build\\Xamarin.Android.Support.Vector.Drawable.targets')\" \/&gt;\r\n  &lt;Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\"&gt;\r\n    &lt;PropertyGroup&gt;\r\n      &lt;ErrorText&gt;This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http:\/\/go.microsoft.com\/fwlink\/?LinkID=322105. The missing file is {0}.&lt;\/ErrorText&gt;\r\n    &lt;\/PropertyGroup&gt;\r\n  &lt;\/Target&gt;\r\n&lt;\/Project&gt;<\/pre>\n<\/div>\n<p>As a last step, you can delete the packages.config file from the project.<\/p>\n<p>If you want to transfer your project to AndroidX, you can find more detailed information <a href=\"https:\/\/sezeromer.com\/xamarin-forms-androidxe-gecis\/\">here<\/a>.<\/p>\n<p>If you have any questions, you can ask by comment or e-mail. Good work.<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>Hello friends, in this article I will talk about how to modernize our old Xamarin projects. Let&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":245,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[289,288,3],"tags":[762,403,765,763,714,767,766,761,764,22,119],"class_list":["post-1862","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","category-ios","category-xamarin-ile-yapilmis-projeler","tag-config","tag-forms","tag-guncelle","tag-modern","tag-package","tag-package-reference","tag-packages-config","tag-reference","tag-update","tag-xamarin","tag-xamarin-forms"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/1862"}],"collection":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/comments?post=1862"}],"version-history":[{"count":6,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/1862\/revisions"}],"predecessor-version":[{"id":2662,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/1862\/revisions\/2662"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media\/245"}],"wp:attachment":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media?parent=1862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/categories?post=1862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/tags?post=1862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}