从复制的package.config添加引用

时间:2017-02-06 07:30:40

标签: c# visual-studio-2015 nuget nuget-package-restore

我想将项目的packages.config复制到新创建的项目中,并在VS2015 SP3中添加引用。

This post介绍Update-Package -Reinstall -ProjectName Your.Project.Name,但它无法正常工作。并非所有软件包都添加到项目中,即使它具有相同的构建环境(.NET 4.5.2控制台应用程序)。此外,它会在重新安装过程之后将packages.config覆盖为仅添加的包。

如何正确地做到这一点?

+附加以下是我的实际packages.config内容。

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.Azure.WebJobs" version="1.1.2" targetFramework="net452" />
  <package id="Microsoft.Azure.WebJobs.Core" version="1.1.2" targetFramework="net452" />
  <package id="Microsoft.Azure.WebJobs.Extensions" version="1.0.1" targetFramework="net452" />
  <package id="Microsoft.Data.Edm" version="5.8.1" targetFramework="net452" />
  <package id="Microsoft.Data.OData" version="5.8.1" targetFramework="net452" />
  <package id="Microsoft.Data.Services.Client" version="5.8.1" targetFramework="net452" />
  <package id="Microsoft.EntityFrameworkCore" version="1.1.0" targetFramework="net452" />
  <package id="Microsoft.EntityFrameworkCore.Relational" version="1.1.0" targetFramework="net452" />
  <package id="Microsoft.EntityFrameworkCore.SqlServer" version="1.1.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.Caching.Abstractions" version="1.1.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.Caching.Memory" version="1.1.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.DependencyInjection" version="1.1.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="1.1.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.Logging" version="1.1.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.Logging.Abstractions" version="1.1.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.Options" version="1.1.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.Primitives" version="1.1.0" targetFramework="net452" />
  <package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net452" />
  <package id="Microsoft.Tpl.Dataflow" version="4.5.24" targetFramework="net452" />
  <package id="Microsoft.Web.WebJobs.Publish" version="1.0.12" targetFramework="net452" />
  <package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.3" targetFramework="net452" />
  <package id="ncrontab" version="2.0.0" targetFramework="net452" />
  <package id="NETStandard.Library" version="1.6.1" targetFramework="net452" />
  <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
  <package id="Remotion.Linq" version="2.1.1" targetFramework="net452" />
  <package id="SimpleInjector" version="3.3.2" targetFramework="net452" />
  <package id="SimpleInjector.Extensions.ExecutionContextScoping" version="3.3.2" targetFramework="net452" />
  <package id="SlowCheetah" version="2.5.15" 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.Collections.Immutable" version="1.3.1" targetFramework="net452" />
  <package id="System.ComponentModel" version="4.3.0" targetFramework="net452" />
  <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net452" />
  <package id="System.Diagnostics.DiagnosticSource" 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.Globalization" version="4.3.0" targetFramework="net452" />
  <package id="System.Interactive.Async" version="3.0.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.3.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.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.CompilerServices.Unsafe" 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.1" 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.0.1" targetFramework="net452" />
</packages>

1 个答案:

答案 0 :(得分:1)

重新安装过程完成后,请接受重新加载或重新加载。

我在接受Reload或Reload All后,在重新安装过程中从磁盘加载更新项目后得到了相同的结果。因为您的项目在接受重新加载或重新加载后卸载并且正在重新安装的过程正在进行中。在项目卸载期间无法将软件包安装到项目中,NuGet会在项目卸载之前将package.config写入仅添加的软件包。

此问题的解决方案是在重新安装过程完成后接受重新加载或重新加载。

<强>更新

重新安装期间检测到冲突文件修改有不同的提示。重新安装过程完成后,请接受重新加载或覆盖。 enter image description here