简体   繁体   中英

(Nuget PackageReference) Xamarin app builds even when I don't add a reference to Xamarin.Forms

I have a solution with a bunch of Xamarin.Forms cross-platform apps. I'm in the middle of a refactoring where I'm migrating things to Nuget PackageReferences. While doing so I encountered a few problems with portable app projects that referenced Xamarin.Forms, so I decided to uninstall the package from these apps and re-install it, then everything worked perfectly. While doing so, however, I realized that if I didn't reinstall Xamarin.Forms on the portable app package, things would still compile and work.

Can someone please explain to me how it's possible that a C# project that contains Xamarin.Forms code in it doesn't need to have a reference to the Xamarin.Forms package to compile? And does this have to do with Nuget PackageReferences? 在此处输入图像描述

Syncfusion.Xamarin.SfChart has a Xamarin.Forms dependency and thus it is auto-added to your project.

Dependencies

  • Syncfusion.Xamarin.Core (>= 18.2.0.54)
  • Xamarin.Forms (>= 3.6.0.344457)

re: https://www.nuget.org/packages/Syncfusion.Xamarin.SfChart

as it is well explained before another package has a reference to Xamarin.Forms, but... that's my addition to the response. I see in your code that you have a using Xamarin.Forms; statement, you are adding it as an indirect reference and then you are adding it to that part of code in a using statement that is not erroring. If that should not be added, then it will show with an underlying red mark, then in an error.

For more information about references, please go to https://docs.microsoft.com/en-us/visualstudio/ide/managing-references-in-a-project?view=vs-2019

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM