添加到我的项目的NuGet包未引用

时间:2019-04-18 19:48:38

标签: xamarin.forms nuget-package nuget-package-restore

还原NuGet程序包时,我看到Xamarin.ios.CameraViewController已还原到我的程序包及其所有依赖项中。但是我从未引用过Xamarin.ios.CameriaViewController,也没有引用过我的软件包。

我的csproj nuget参考文献:

<ItemGroup>
<PackageReference Include="Acr.UserDialogs">
  <Version>7.0.3</Version>
</PackageReference>
<PackageReference Include="CarouselView.FormsPlugin">
  <Version>5.2.0</Version>
</PackageReference>
<PackageReference Include="DLToolkit.Forms.Controls.FlowListView">
  <Version>2.0.11</Version>
</PackageReference>
<PackageReference Include="GMImagePicker.Xamarin">
  <Version>2.3.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.Net.Http">
  <Version>2.2.29</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
  <Version>12.0.1</Version>
</PackageReference>
<PackageReference Include="Plugin.FacebookClient">
  <Version>1.4.0</Version>
</PackageReference>
<PackageReference Include="Plugin.FileUploader">
  <Version>1.4.0</Version>
</PackageReference>
<PackageReference Include="Plugin.GoogleClient">
  <Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Remote.Linq.Newtonsoft.Json">
  <Version>5.8.2</Version>
</PackageReference>
<PackageReference Include="Rg.Plugins.Popup">
  <Version>1.1.5.188</Version>
</PackageReference>
<PackageReference Include="SQLite.Net.Async-PCL">
  <Version>3.1.1</Version>
</PackageReference>
<PackageReference Include="SQLite.Net.Core-PCL">
  <Version>3.1.1</Version>
</PackageReference>
<PackageReference Include="Syncfusion.Xamarin.SfAutoComplete">
  <Version>16.4.0.54</Version>
</PackageReference>
<PackageReference Include="Xam.Plugin.Connectivity">
  <Version>3.2.0</Version>
</PackageReference>
<PackageReference Include="Xam.Plugin.Media">
  <Version>4.0.1.5</Version>
</PackageReference>
<PackageReference Include="Xam.Plugins.Forms.ImageCircle">
  <Version>3.0.0.5</Version>
</PackageReference>
<PackageReference Include="Xam.Plugins.Messaging">
  <Version>5.2.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Essentials">
  <Version>1.0.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="3.4.0.1029999" />
<PackageReference Include="System.Reflection.Emit">
  <Version>4.3.0</Version>
  <ExcludeAssets>all</ExcludeAssets>
</PackageReference>
<PackageReference Include="Xamarin.Forms.ImagePicker">
  <Version>1.0.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Google.iOS.SignIn">
  <Version>4.4.0</Version>
</PackageReference>
<PackageReference Include="Xamd.Plugins.Forms.ImageCarousel">
  <Version>1.0.2</Version>
</PackageReference>
<PackageReference Include="Xfx.Controls">
  <Version>1.1.3</Version>
</PackageReference>
</ItemGroup>

那么为什么要引用它?如何删除它?

2 个答案:

答案 0 :(得分:3)

它是Xamarin.Forms.ImagePicker.iOS的依赖项,也是Xamarin.Forms.ImagePicker的依赖项。

答案 1 :(得分:1)

  • 仅在项目文件中维护包引用 其中列出了顶级依赖项,即您拥有的软件包 明确添加。
  • 现在,软件包可以依赖于其他软件包。这些 包成为您的传递依赖项-您所做的包 没有显式添加,但现在您隐式依赖它们。
  • 大多数时候您对它们都不在乎,这就是为什么它们不会出现在 已安装软件包的列表,即顶级依赖项。
  • 不过,您可以查看所有依赖项,包括传递性依赖项- 打开项目的obj目录。您会看到projects.assetes.json,您会看到类似的信息

    "Microsoft.NETCore.UniversalWindowsPlatform/6.2.8": {
     "type": "package",
     "dependencies": {
       "Microsoft.NETCore.Platforms": "2.1.0",
       "Microsoft.Net.Native.Compiler": "2.2.3",
       "Microsoft.Net.UWPCoreRuntimeSdk": "2.2.8",
       "NETStandard.Library": "2.0.3"
    }
    

在该示例中,Microsoft.NETCore.UniversalWindowsPlatform是一个显式安装的软件包,可以在csproj引用中看到,但它也带来了很多依赖项,例如Microsoft.NETCore.PlatformsMicrosoft.Net.Native.Compiler,等