Swathi
Swathi

Reputation: 157

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

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

Upvotes: 6

Views: 11430

Answers (4)

Aage
Aage

Reputation: 6252

For me this error occurred when running dotnet list package --vulnerable --include-transitive (a check for vulnerable packages), but the root cause was our private package repository which we use next to nuget.org.

Temporarily disabling this did the trick:

  1. Run dotnet list package --vulnerable --include-transitive, this should output mentioned error
  2. Run dotnet nuget list source, this outputs two sources (e.g. Nuget and Local)
  3. Assuming Local is the problem, run dotnet nuget disable source Local
  4. Re-run dotnet list package --vulnerable --include-transitive and verify that error is gone
  5. Optionally, enable package source again with dotnet nuget enable source Local

Upvotes: 0

webMac
webMac

Reputation: 203

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.

Upvotes: -1

John J Smith
John J Smith

Reputation: 11923

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.

Upvotes: 1

Mr Qian
Mr Qian

Reputation: 23740

'' 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.

Upvotes: 1

Related Questions