'' is not a valid version string." exception in nuget for VS2019

Viewed 6546

I have installed VS 2019 today removing all other versions of VS (over come space crunch). Am trying to use nuget package manager but keep getting below exception. Nothing loads. I tried to install packages from console and ended up with same error as below. Any help would be appreciated.

PM> Install-Package Microsoft.Azure.Devices -Version 1.21.0 Install-Package : '' is not a valid version string. At line:1 char:1 + Install-Package Microsoft.Azure.Devices -Version 1.21.0 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], Exception + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Time Elapsed: 00:00:00.6338016

3 Answers

I tried the solution above (deleting all the installed Nuget packages, .vm folder, etc) but it didn't work for me. I was on Visual Studio 2019 v 16.8.4. Updating to Version 16.8.5 solved this issue for me.

'' is not a valid version string." exception in nuget for VS2019

You can try these steps:

1) first, check whether you can access the nuget package on Nuget Package Manager UI(Right-click on your project-->Manage Nuget Packages)

2) clean all nuget caches or delete all files under C:\Users\(user name)xxx\.nuget\packages

3) close VS Instance, delete .vs hidden folder under your solution folder ,bin and obj folder, delete C:\Users\xxx\AppData\Roaming\NuGet\NuGet.Config and then restart VS to test again.

4) add a new nuget package source and then add this in it as nuget.org path:

http://packages.nuget.org/v1/FeedService.svc/.

Enable it and test again.

5) please run this command on Package Manager Console:

Install-Package Microsoft.Azure.Devices -Version 1.21.0

Also, please make sure that you select the right project to install this package.

enter image description here

6) check if there is a firewall policy or other proxy settings that block the nuget installation package

In addition, you could try to create a new project to test whether this issue persists in it.

=======================================

Update 1 Solution

First, thanks to you for trying the method for creating a new project.

Just create a project and then migrate all the old project files into the the new project. This solves the issue.

In my case another broken csproj file in the solution caused the problem.

Found it by divide-and-conquer removing projects from the solution. Turns out a parameter in that other csproj file caused VS and NuGet Manager to malfunction.

Hope this helps someone else too.

Related