简体   繁体   中英

How to fix $(NETStandardImplicitPackageVersion) error when adding nuget packages to .net core project with older solution?

We have an existing .NET Solution with a lot of projects. I've recently added a new ASP.NET core project to the solution. When I try to add a Nuget package to the solution, the add fails and I get the following error in the Package Manager output window. If I create a new solution and add the same project to the solution then I'm able to add Nuget packages so it seems to be an issue with adding new .NET core projects to an existing solution. Can anyone help me get past this without needing to recreate the solution?

System.ArgumentException: '$(NETStandardImplicitPackageVersion)' is not a valid version string. at NuGet.Versioning.VersionRange.Parse(String value, Boolean allowFloating) at
NuGet.PackageManagement.VisualStudio.VsManagedLanguagesProjectSystemServices.ToPackageLibraryDependency(PackageReference reference) at System.Linq.Enumerable.WhereSelectEnumerableIterator 2.MoveNext()
at System.Collections.Generic.List
2.MoveNext()
at System.Collections.Generic.List
2.MoveNext()
at System.Collections.Generic.List
1..ctor(IEnumerable 1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source) at NuGet.PackageManagement.VisualStudio.VsManagedLanguagesProjectSystemServices.d__23.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)

at NuGet.PackageManagement.VisualStudio.LegacyPackageReferenceProject.d__27.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.PackageManagement.VisualStudio.LegacyPackageReferenceProject.d__14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.PackageManagement.DependencyGraphRestoreUtility.d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task tas k) at NuGet.PackageManagement.DependencyGraphRestoreUtility.d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at NuGet.PackageManagement.NuGetPackageManager.d__75.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

Not sure if this is the same issue as the one I encountered, but, for me, what fixed it was making sure the GUIDs I had in my sln file matched.

For example:

Project("{PROJECT-GUID}") = "ProjectA", "ProjectA\ProjectA.csproj", "{GUID-PROJECT-A}"
EndProject
Project("{PROJECT-GUID}") = "ProjectB", "ProjectB\ProjectB.csproj", "{GUID-PROJECT-B}"
EndProject
Project("{SOME-OTHER-GUID}") = "ProjectC", "ProjectC\ProjectC.csproj", "{GUID-PROJECT-C}"
EndProject

I had to replace SOME-OTHER-GUID with PROJECT-GUID.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM