为什么在使用命令Update-Package --reinstall后安装了新软件包

时间:2018-05-29 14:06:20

标签: visual-studio nuget nuget-package nuget-package-restore

我有一个解决方案,其中几乎没有nuget包。

这些包引用了不同的网络框架。例如。很少有人针对net451,有些针对net452,有些则针对net461。

我的项目有net461框架。所以我使用命令Update-Package --reinstall重新安装目标net461框架的软件包。

成功了,但我不确定为什么还有更多的软件包已经添加了?

更新我的套餐之前。

<package id="EnterpriseLibrary.Common" version="6.0.1304.0" targetFramework="net451" />
  <package id="EnterpriseLibrary.TransientFaultHandling" version="6.0.1304.0" targetFramework="net451" />
  <package id="EnterpriseLibrary.TransientFaultHandling.Caching" version="6.0.1304.0" targetFramework="net451" />
  <package id="EnterpriseLibrary.TransientFaultHandling.Configuration" version="6.0.1304.0" targetFramework="net451" />
  <package id="EnterpriseLibrary.TransientFaultHandling.Data" version="6.0.1304.1" targetFramework="net451" />
  <package id="EnterpriseLibrary.TransientFaultHandling.ServiceBus" version="6.0.1304.0" targetFramework="net451" />
  <package id="EnterpriseLibrary.TransientFaultHandling.WindowsAzure.Storage" version="6.0.1304.0" targetFramework="net451" />
  <package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net451" />
  <package id="Microsoft.Data.Edm" version="5.8.2" targetFramework="net452" />
  <package id="Microsoft.Data.OData" version="5.8.2" targetFramework="net452" />
  <package id="Microsoft.Data.Services.Client" version="5.8.2" targetFramework="net452" />
  <package id="Microsoft.Extensions.DependencyInjection" version="2.0.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.0.0" targetFramework="net461" />
  <package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net452" />
  <package id="NETStandard.Library" version="1.6.1" targetFramework="net452" />
  <package id="Newtonsoft.Json" version="8.0.2" targetFramework="net452" />
  <package id="System.Collections" version="4.3.0" targetFramework="net452" />
  <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net452" />
  <package id="System.ComponentModel" version="4.3.0" targetFramework="net452" />
  <package id="System.ComponentModel.EventBasedAsync" version="4.0.11" targetFramework="net452" />
  <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net452" />
  <package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net452" />
  <package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net452" />
  <package id="System.Dynamic.Runtime" version="4.0.0" targetFramework="net452" />
  <package id="System.Globalization" version="4.3.0" targetFramework="net452" />
  <package id="System.IO" version="4.3.0" targetFramework="net452" />
  <package id="System.IO.Compression" version="4.3.0" targetFramework="net452" />
  <package id="System.Linq" version="4.3.0" targetFramework="net452" />
  <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net452" />
  <package id="System.Linq.Queryable" version="4.0.0" targetFramework="net452" />
  <package id="System.Net.Http" version="4.3.0" targetFramework="net452" />
  <package id="System.Net.Primitives" version="4.3.0" targetFramework="net452" />
  <package id="System.Net.Requests" version="4.0.11" targetFramework="net452" />
  <package id="System.ObjectModel" version="4.3.0" targetFramework="net452" />
  <package id="System.Reflection" version="4.3.0" targetFramework="net452" />
  <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net452" />
  <package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net452" />
  <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net452" />
  <package id="System.Runtime" version="4.3.0" targetFramework="net452" />
  <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net452" />
  <package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net452" />
  <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net452" />
  <package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net452" />
  <package id="System.Spatial" version="5.8.2" targetFramework="net452" />
  <package id="System.Text.Encoding" version="4.3.0" targetFramework="net452" />
  <package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net452" />
  <package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net452" />
  <package id="System.Threading" version="4.3.0" targetFramework="net452" />
  <package id="System.Threading.Tasks" version="4.3.0" targetFramework="net452" />
  <package id="System.Threading.Timer" version="4.3.0" targetFramework="net452" />
  <package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net452" />
  <package id="System.Xml.XDocument" version="4.3.0" targetFramework="net452" />
  <package id="WindowsAzure.Storage" version="8.1.1" targetFramework="net452" />

更新我的套餐后

<package id="EnterpriseLibrary.Common" version="6.0.1304.0" targetFramework="net461" />
  <package id="EnterpriseLibrary.TransientFaultHandling" version="6.0.1304.0" targetFramework="net461" />
  <package id="EnterpriseLibrary.TransientFaultHandling.Caching" version="6.0.1304.0" targetFramework="net461" />
  <package id="EnterpriseLibrary.TransientFaultHandling.Configuration" version="6.0.1304.0" targetFramework="net461" />
  <package id="EnterpriseLibrary.TransientFaultHandling.Data" version="6.0.1304.1" targetFramework="net461" />
  <package id="EnterpriseLibrary.TransientFaultHandling.ServiceBus" version="6.0.1304.0" targetFramework="net461" />
  <package id="EnterpriseLibrary.TransientFaultHandling.WindowsAzure.Storage" version="6.0.1304.1" targetFramework="net461" />
  <package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net461" />
  <package id="Microsoft.Data.Edm" version="5.8.2" targetFramework="net461" />
  <package id="Microsoft.Data.OData" version="5.8.2" targetFramework="net461" />
  <package id="Microsoft.Data.Services.Client" version="5.8.2" targetFramework="net461" />
  <package id="Microsoft.Extensions.DependencyInjection" version="2.0.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.0.0" targetFramework="net461" />
  <package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net461" />
  <package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net461" />
  <package id="NETStandard.Library" version="1.6.1" targetFramework="net461" />
  <package id="Newtonsoft.Json" version="8.0.2" targetFramework="net461" />
  <package id="System.AppContext" version="4.3.0" targetFramework="net461" />
  <package id="System.Collections" version="4.3.0" targetFramework="net461" />
  <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net461" />
  <package id="System.ComponentModel" version="4.3.0" targetFramework="net461" />
  <package id="System.ComponentModel.EventBasedAsync" version="4.0.11" targetFramework="net461" />
  <package id="System.Console" version="4.3.0" targetFramework="net461" />
  <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net461" />
  <package id="System.Diagnostics.DiagnosticSource" version="4.3.0" targetFramework="net461" />
  <package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net461" />
  <package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net461" />
  <package id="System.Dynamic.Runtime" version="4.0.0" targetFramework="net461" />
  <package id="System.Globalization" version="4.3.0" targetFramework="net461" />
  <package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net461" />
  <package id="System.IO" version="4.3.0" targetFramework="net461" />
  <package id="System.IO.Compression" version="4.3.0" targetFramework="net461" />
  <package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net461" />
  <package id="System.IO.FileSystem" version="4.3.0" targetFramework="net461" />
  <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net461" />
  <package id="System.Linq" version="4.3.0" targetFramework="net461" />
  <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net461" />
  <package id="System.Linq.Queryable" version="4.0.0" targetFramework="net461" />
  <package id="System.Net.Http" version="4.3.0" targetFramework="net461" />
  <package id="System.Net.Primitives" version="4.3.0" targetFramework="net461" />
  <package id="System.Net.Requests" version="4.0.11" targetFramework="net461" />
  <package id="System.Net.Sockets" version="4.3.0" targetFramework="net461" />
  <package id="System.ObjectModel" version="4.3.0" targetFramework="net461" />
  <package id="System.Reflection" version="4.3.0" targetFramework="net461" />
  <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net461" />
  <package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net461" />
  <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net461" />
  <package id="System.Runtime" version="4.3.0" targetFramework="net461" />
  <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net461" />
  <package id="System.Runtime.Handles" version="4.3.0" targetFramework="net461" />
  <package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net461" />
  <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net461" />
  <package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net461" />
  <package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net461" />
  <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net461" />
  <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net461" />
  <package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net461" />
  <package id="System.Spatial" version="5.8.2" targetFramework="net461" />
  <package id="System.Text.Encoding" version="4.3.0" targetFramework="net461" />
  <package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net461" />
  <package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net461" />
  <package id="System.Threading" version="4.3.0" targetFramework="net461" />
  <package id="System.Threading.Tasks" version="4.3.0" targetFramework="net461" />
  <package id="System.Threading.Timer" version="4.3.0" targetFramework="net461" />
  <package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net461" />
  <package id="System.Xml.XDocument" version="4.3.0" targetFramework="net461" />
  <package id="WindowsAzure.Storage" version="8.1.1" targetFramework="net461" />

1 个答案:

答案 0 :(得分:1)

  

但我不确定为什么还有更多的软件包已经添加了?

这是NuGet的默认行为。当我们将nuget包安装到项目中时,nuget还会将其依赖项添加到项目中。

原因为什么添加更多软件包的原因是依赖关系在定位不同框架时有所不同。在定位.net461时,某些软件包会为项目引入更多依赖项。所以你已经添加了更多的软件包。

例如,您可以检查包Microsoft.Extensions.DependencyInjectionSystem.Net.HttpSystem.Runtime.InteropServices的依赖关系:

enter image description here

enter image description here

显然,当您使用命令Update-Package -reinstall重新安装面向net461框架的软件包时,这些软件包将为项目添加一些新的依赖项。

希望这有帮助。