gpt4 book ai didi

c# - 安装 nuget 包 "same key has already been added."

转载 作者:IT王子 更新时间:2023-10-29 04:16:20 29 4
gpt4 key购买 nike

我正在尝试安装 Microsoft.Bcl.Build 1.0.14

nuget 返回

Installing 'Microsoft.Bcl.Build 1.0.14'. Successfully installed 'Microsoft.Bcl.Build 1.0.14'. Adding 'Microsoft.Bcl.Build 1.0.14' to LeadTracker.Calendar. Uninstalling 'Microsoft.Bcl.Build 1.0.14'. Successfully uninstalled 'Microsoft.Bcl.Build 1.0.14'. Install failed. Rolling back... An item with the same key has already been added.

json.net 和其他包也会发生这种情况。

我可以添加 nancy 和 topshelf,但不能添加 json.net 和 bcl。

我在VS2012和2013都试过了,我也试过卸载nuget再重装。我还尝试将 nuget 添加到一个空的类库和一个空的控制台应用程序中。总是返回相同的错误。

json.net 和其他包也会发生这种情况。

我也试过没有包文件

最受赞赏的任何想法。

这是命令和堆栈跟踪

PM> Install-Package Microsoft.Bcl.Build Installing 'Microsoft.Bcl.Build 1.0.14'. You are downloading Microsoft.Bcl.Build from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=329770. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device. Successfully installed 'Microsoft.Bcl.Build 1.0.14'. Adding 'Microsoft.Bcl.Build 1.0.14' to GoogleCalendarIntegration. Uninstalling 'Microsoft.Bcl.Build 1.0.14'. Successfully uninstalled 'Microsoft.Bcl.Build 1.0.14'. Install failed. Rolling back... Install-Package : An item with the same key has already been added. At line:1 char:1
+ Install-Package Microsoft.Bcl.Build
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], ArgumentException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPac kageCommand PM> $error[0].exception.stacktrace at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item) at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item) at System.Collections.ObjectModel.Collection`1.Add(T item) at NuGet.CollectionExtensions.AddRange[T](ICollection`1 collection, IEnumerable`1 items) at NuGet.NetPortableProfileTable.BuildPortableProfileCollection() at NuGet.NetPortableProfileTable.get_Profiles() at NuGet.NetPortableProfileTable.GetProfile(String profileName) at NuGet.NetPortableProfile.Parse(String profileValue, Boolean treatOptionalFrameworksAsSuppor tedFrameworks) at NuGet.VersionUtility.IsPortableLibraryCompatible(FrameworkName projectFrameworkName, Framew orkName packageTargetFrameworkName) at NuGet.VersionUtility.IsCompatible(FrameworkName projectFrameworkName, FrameworkName package TargetFrameworkName) at NuGet.VersionUtility.<>c__DisplayClass8`1.<TryGetCompatibleItems>b__15(IGrouping`2 g) at System.Linq.Enumerable.WhereListIterator`1.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source) at NuGet.VersionUtility.TryGetCompatibleItems[T](FrameworkName projectFramework, IEnumerable`1 items, IEnumerable`1& compatibleItems) at NuGet.ProjectSystemExtensions.GetCompatibleItemsCore[T](IProjectSystem projectSystem, IEnum erable`1 items) at NuGet.ProjectManager.ExtractPackageFilesToProject(IPackage package) at NuGet.ProjectManager.AddPackageReferenceToProject(IPackage package) at NuGet.ProjectManager.Execute(PackageOperation operation) at NuGet.ProjectManager.Execute(IPackage package, IPackageOperationResolver resolver) at NuGet.ProjectManager.AddPackageReference(IPackage package, Boolean ignoreDependencies, Bool ean allowPrereleaseVersions) at NuGet.VisualStudio.VsPackageManager.<>c__DisplayClass83.<AddPackageReference>b__85() at NuGet.VisualStudio.VsPackageManager.RunProjectAction(IProjectManager projectManager, Action action) at NuGet.VisualStudio.VsPackageManager.AddPackageReference(IProjectManager projectManager, IPa ckage package, Boolean ignoreDependencies, Boolean allowPrereleaseVersions) at NuGet.VisualStudio.VsPackageManager.<>c__DisplayClass3.<InstallPackage>b__7() at NuGet.VisualStudio.VsPackageManager.RunSolutionAction(Action action) at NuGet.VisualStudio.VsPackageManager.InstallPackage(IProjectManager projectManager, String p ackageId, SemanticVersion version, Boolean ignoreDependencies, Boolean allowPrereleaseVersions, B oolean skipAssemblyReferences, ILogger logger) at NuGet.VisualStudio.VsPackageManager.InstallPackage(IProjectManager projectManager, String p ackageId, SemanticVersion version, Boolean ignoreDependencies, Boolean allowPrereleaseVersions, I Logger logger) at NuGet.PowerShell.Commands.InstallPackageCommand.InstallPackage(IVsPackageManager packageMan ager) at NuGet.PowerShell.Commands.InstallPackageCommand.ProcessRecordCore() at NuGet.PowerShell.Commands.NuGetBaseCommand.ProcessRecord() PM>

最佳答案

检查您的 packages.config 在里面,检查您要安装的包。也许一些引用已经存在,这避免了您可以安装新的引用。

如果您在那里找到引用,请从 packages.config 中删除引用并尝试重新安装包。

我有时会发现,在 packages.config 中有一些旧的引用,即使从 Nuget 包管理器中删除包后,这些引用仍然存在。

如果没有,您可以删除整个 packages.config,然后如果您可以选择让 Nuget 下载包,当您构建解决方案时,将再次下载包。

希望对你有帮助

关于c# - 安装 nuget 包 "same key has already been added.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24429838/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com