我有一个.net5项目,我需要调试此项目使用的库。为此,我已卸载了库的NuGet包,并将项目引用添加到项目中。现在,我无法生成该项目。生成后,我收到以下错误:
The "ResolvePackageDependencies" task failed unexpectedly.
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at Microsoft.NET.Build.Tasks.ResolvePackageDependencies.GetPackageAndFileDependencies(LockFileTarget target)
at Microsoft.NET.Build.Tasks.ResolvePackageDependencies.RaiseLockFileTargets()
at Microsoft.NET.Build.Tasks.ResolvePackageDependencies.ExecuteCore()
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() Project.Namespace C:\Program Files\dotnet\sdk\6.0.202\Sdks\Microsoft.NET.Sdk\targets C:\Program Files\dotnet\sdk\6.0.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets
还有
The "ResolvePackageAssets" task failed unexpectedly
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at Microsoft.NET.Build.Tasks.ProjectContext.GetTopLevelDependencies(LockFile lockFile, LockFileTarget lockFileTarget)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter.ComputePackageExclusions()
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter..ctor(ResolvePackageAssets task)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromDisk(ResolvePackageAssets task, Byte[] settingsHash)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader..ctor(ResolvePackageAssets task)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups()
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore()
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() Project.Namespace C:\Program Files\dotnet\sdk\6.0.202\Sdks\Microsoft.NET.Sdk\targets C:\Program Files\dotnet\sdk\6.0.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets
csproj中没有重复的包。如何解决这个问题?我已经尝试过:
- 删除bin、obj和. vs文件夹
- 还原Nuget软件包
- 清除所有NuGet缓存
谢谢。
2条答案
按热度按时间jgwigjjp1#
我找到了解决方案。问题是另一个Solution项目仍然引用NuGet包而不是本地项目。因此,删除依赖项并添加对本地包的引用就足够了。
vh0rcniy2#
我的问题是Nuget套餐不存在。
溶液