Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.WhereSelectEnumerableIterator2.MoveNext()
at System.Collections.Generic.List
1..ctor(IEnumerable1 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 task) 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)

like image 445
Buddy J Avatar asked Jan 22 '18 13:01

Buddy J


1 Answers

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.

like image 61
Daniel Avatar answered Sep 29 '22 01:09

Daniel